Built motion from commit (unavailable).|2.5.24
[motion2.git] / server / api / whatsappMessage / whatsappMessage.model.js
index 9fdaf7f..72e8be1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x215f=['WhatsappMessage,\x20%s,\x20%s,\x20%s','utf8mb4_unicode_ci','../../config/logger','api','path','../../config/environment','./whatsappMessage.attributes','WhatsappMessage','whatsapp_messages','messageId','fti_whatsapp_messages','body','get','toLowerCase','direction','out','secret','isNil','UserId','findOne','then','update','createdAt','catch','WhatsappAccount','WhatsappAccountId','type','twilio','accountSid','authToken','phone','messages','whatsapp:','remote','/api/whatsapp/messages/','/status?token=','sid','inspect'];(function(_0x815126,_0x378cca){var _0x2d617a=function(_0x191043){while(--_0x191043){_0x815126['push'](_0x815126['shift']());}};_0x2d617a(++_0x378cca);}(_0x215f,0x1f0));var _0xf215=function(_0x38ea85,_0x24dd4b){_0x38ea85=_0x38ea85-0x0;var _0x52c063=_0x215f[_0x38ea85];return _0x52c063;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0xf215('0x0'))(_0xf215('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require(_0xf215('0x2'));var rimraf=require('rimraf');var config=require(_0xf215('0x3'));var attributes=require(_0xf215('0x4'));module['exports']=function(_0x5c5228,_0x5b0ee8){return _0x5c5228['define'](_0xf215('0x5'),attributes,{'tableName':_0xf215('0x6'),'paranoid':![],'indexes':[{'name':_0xf215('0x7'),'fields':['messageId']},{'name':_0xf215('0x8'),'fields':[_0xf215('0x9')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x4e2768,_0x164987,_0x2d1f4c){var _0x2476e2=_0x5c5228['models'];var _0x182e31=_0x4e2768[_0xf215('0xa')]({'plain':!![]});if(_0x182e31['direction'][_0xf215('0xb')]()==='in'||_0x182e31[_0xf215('0xc')][_0xf215('0xb')]()===_0xf215('0xd')&&!_0x182e31[_0xf215('0xe')]&&!_[_0xf215('0xf')](_0x182e31[_0xf215('0x10')])){_0x2476e2['WhatsappInteraction'][_0xf215('0x11')]({'where':{'id':_0x182e31['WhatsappInteractionId']}})[_0xf215('0x12')](function(_0x136644){if(_0x136644){_0x136644[_0xf215('0x13')]({'lastMsgAt':_0x182e31[_0xf215('0x14')],'lastMsgDirection':_0x182e31[_0xf215('0xc')][_0xf215('0xb')]()});}})[_0xf215('0x15')](function(_0x75e14a){console['error'](_0x75e14a);});}if(_0x182e31['direction']===_0xf215('0xd')&&!_0x182e31['secret']){var _0x5294c8;_0x2476e2[_0xf215('0x16')]['find']({'where':{'id':_0x182e31[_0xf215('0x17')]},'raw':!![]})['then'](function(_0x1ce8b3){_0x5294c8=_0x1ce8b3;if(_0x5294c8&&_0x5294c8[_0xf215('0x18')]){switch(_0x5294c8[_0xf215('0x18')]){case _0xf215('0x19'):var _0x53f76c=require(_0xf215('0x19'));if(_0x5294c8[_0xf215('0x1a')]&&_0x5294c8[_0xf215('0x1b')]&&_0x5294c8[_0xf215('0x1c')]){var _0x149ba7=new _0x53f76c(_0x5294c8[_0xf215('0x1a')],_0x5294c8[_0xf215('0x1b')]);_0x149ba7[_0xf215('0x1d')]['create']({'body':_0x182e31[_0xf215('0x9')],'to':'whatsapp:'+_0x182e31[_0xf215('0x1c')],'from':_0xf215('0x1e')+_0x5294c8[_0xf215('0x1c')],'statusCallback':_0x5294c8[_0xf215('0x1f')]+_0xf215('0x20')+_0x182e31['id']+_0xf215('0x21')+_0x5294c8['token']})[_0xf215('0x12')](function(_0x3161e4){if(_0x3161e4[_0xf215('0x22')]){return _0x4e2768[_0xf215('0x13')]({'messageId':_0x3161e4[_0xf215('0x22')]});}})[_0xf215('0x15')](function(_0x5e50a7){logger['error']('WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','twilio',util[_0xf215('0x23')](_0x5e50a7,{'showHidden':![],'depth':null}));});}else{logger['error'](_0xf215('0x24'),'afterCreate','twilio','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken');}break;}}})['finally'](function(){_0x2d1f4c();});}else{_0x2d1f4c();}}},'charset':'utf8mb4','collate':_0xf215('0x25')});};
\ No newline at end of file
+var _0x3aae=['WhatsappMessage,\x20%s,\x20%s,\x20%s','finally','utf8mb4','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./whatsappMessage.attributes','exports','define','WhatsappMessage','whatsapp_messages','messageId','fti_whatsapp_messages','body','FULLTEXT','toLowerCase','out','secret','isNil','UserId','WhatsappInteraction','findOne','WhatsappInteractionId','then','update','createdAt','direction','error','WhatsappAccount','find','type','twilio','accountSid','phone','authToken','messages','create','whatsapp:','remote','/api/whatsapp/messages/','token','sid','catch','inspect'];(function(_0x4c1991,_0x11a24b){var _0x4fbd4a=function(_0x4f478f){while(--_0x4f478f){_0x4c1991['push'](_0x4c1991['shift']());}};_0x4fbd4a(++_0x11a24b);}(_0x3aae,0x102));var _0xe3aa=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0x3aae[_0xa464c9];return _0x3d73c4;};'use strict';var _=require(_0xe3aa('0x0'));var util=require(_0xe3aa('0x1'));var logger=require(_0xe3aa('0x2'))(_0xe3aa('0x3'));var moment=require(_0xe3aa('0x4'));var BPromise=require(_0xe3aa('0x5'));var rp=require(_0xe3aa('0x6'));var fs=require('fs');var path=require(_0xe3aa('0x7'));var rimraf=require(_0xe3aa('0x8'));var config=require(_0xe3aa('0x9'));var attributes=require(_0xe3aa('0xa'));module[_0xe3aa('0xb')]=function(_0x5426a5,_0xfda58){return _0x5426a5[_0xe3aa('0xc')](_0xe3aa('0xd'),attributes,{'tableName':_0xe3aa('0xe'),'paranoid':![],'indexes':[{'name':_0xe3aa('0xf'),'fields':[_0xe3aa('0xf')]},{'name':_0xe3aa('0x10'),'fields':[_0xe3aa('0x11')],'type':_0xe3aa('0x12')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x421922,_0x46afb4,_0x20d13f){var _0x329352=_0x5426a5['models'];var _0x582ae6=_0x421922['get']({'plain':!![]});if(_0x582ae6['direction']['toLowerCase']()==='in'||_0x582ae6['direction'][_0xe3aa('0x13')]()===_0xe3aa('0x14')&&!_0x582ae6[_0xe3aa('0x15')]&&!_[_0xe3aa('0x16')](_0x582ae6[_0xe3aa('0x17')])){_0x329352[_0xe3aa('0x18')][_0xe3aa('0x19')]({'where':{'id':_0x582ae6[_0xe3aa('0x1a')]}})[_0xe3aa('0x1b')](function(_0x2e09f5){if(_0x2e09f5){_0x2e09f5[_0xe3aa('0x1c')]({'lastMsgAt':_0x582ae6[_0xe3aa('0x1d')],'lastMsgDirection':_0x582ae6[_0xe3aa('0x1e')][_0xe3aa('0x13')]()});}})['catch'](function(_0x22368e){console[_0xe3aa('0x1f')](_0x22368e);});}if(_0x582ae6['direction']==='out'&&!_0x582ae6[_0xe3aa('0x15')]){var _0x14f175;_0x329352[_0xe3aa('0x20')][_0xe3aa('0x21')]({'where':{'id':_0x582ae6['WhatsappAccountId']},'raw':!![]})[_0xe3aa('0x1b')](function(_0x2dd2da){_0x14f175=_0x2dd2da;if(_0x14f175&&_0x14f175[_0xe3aa('0x22')]){switch(_0x14f175['type']){case _0xe3aa('0x23'):var _0x4ea55e=require('twilio');if(_0x14f175[_0xe3aa('0x24')]&&_0x14f175['authToken']&&_0x14f175[_0xe3aa('0x25')]){var _0xf29ddb=new _0x4ea55e(_0x14f175['accountSid'],_0x14f175[_0xe3aa('0x26')]);_0xf29ddb[_0xe3aa('0x27')][_0xe3aa('0x28')]({'body':_0x582ae6[_0xe3aa('0x11')],'to':_0xe3aa('0x29')+_0x582ae6[_0xe3aa('0x25')],'from':_0xe3aa('0x29')+_0x14f175[_0xe3aa('0x25')],'statusCallback':_0x14f175[_0xe3aa('0x2a')]+_0xe3aa('0x2b')+_0x582ae6['id']+'/status?token='+_0x14f175[_0xe3aa('0x2c')]})[_0xe3aa('0x1b')](function(_0x53e4ff){if(_0x53e4ff[_0xe3aa('0x2d')]){return _0x421922['update']({'messageId':_0x53e4ff[_0xe3aa('0x2d')]});}})[_0xe3aa('0x2e')](function(_0xcc9a62){logger[_0xe3aa('0x1f')]('WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','twilio',util[_0xe3aa('0x2f')](_0xcc9a62,{'showHidden':![],'depth':null}));});}else{logger[_0xe3aa('0x1f')](_0xe3aa('0x30'),'afterCreate',_0xe3aa('0x23'),'Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken');}break;}}})[_0xe3aa('0x31')](function(){_0x20d13f();});}else{_0x20d13f();}}},'charset':_0xe3aa('0x32'),'collate':'utf8mb4_unicode_ci'});};
\ No newline at end of file