Built motion from commit (unavailable).|2.5.24
[motion2.git] / server / api / whatsappMessage / whatsappMessage.model.js
index ffa92c5..72e8be1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x94e3=['inspect','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','finally','utf8mb4_unicode_ci','util','api','bluebird','request-promise','path','rimraf','exports','WhatsappMessage','whatsapp_messages','messageId','fti_whatsapp_messages','body','FULLTEXT','models','get','direction','toLowerCase','secret','isNil','WhatsappInteraction','findOne','WhatsappInteractionId','then','update','createdAt','catch','out','find','type','twilio','phone','accountSid','authToken','messages','create','whatsapp:','remote','/status?token=','token','error','WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate'];(function(_0x33975c,_0x50d085){var _0x1c15ab=function(_0x54e8bc){while(--_0x54e8bc){_0x33975c['push'](_0x33975c['shift']());}};_0x1c15ab(++_0x50d085);}(_0x94e3,0x146));var _0x394e=function(_0x5bf0dc,_0xbe98){_0x5bf0dc=_0x5bf0dc-0x0;var _0x27a90e=_0x94e3[_0x5bf0dc];return _0x27a90e;};'use strict';var _=require('lodash');var util=require(_0x394e('0x0'));var logger=require('../../config/logger')(_0x394e('0x1'));var moment=require('moment');var BPromise=require(_0x394e('0x2'));var rp=require(_0x394e('0x3'));var fs=require('fs');var path=require(_0x394e('0x4'));var rimraf=require(_0x394e('0x5'));var config=require('../../config/environment');var attributes=require('./whatsappMessage.attributes');module[_0x394e('0x6')]=function(_0x388b62,_0xd24ebb){return _0x388b62['define'](_0x394e('0x7'),attributes,{'tableName':_0x394e('0x8'),'paranoid':![],'indexes':[{'name':_0x394e('0x9'),'fields':[_0x394e('0x9')]},{'name':_0x394e('0xa'),'fields':[_0x394e('0xb')],'type':_0x394e('0xc')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x54538a,_0x35d846,_0x4bd532){var _0x2e2ac2=_0x388b62[_0x394e('0xd')];var _0x3ca317=_0x54538a[_0x394e('0xe')]({'plain':!![]});if(_0x3ca317[_0x394e('0xf')][_0x394e('0x10')]()==='in'||_0x3ca317['direction'][_0x394e('0x10')]()==='out'&&!_0x3ca317[_0x394e('0x11')]&&!_[_0x394e('0x12')](_0x3ca317['UserId'])){_0x2e2ac2[_0x394e('0x13')][_0x394e('0x14')]({'where':{'id':_0x3ca317[_0x394e('0x15')]}})[_0x394e('0x16')](function(_0xff926e){if(_0xff926e){_0xff926e[_0x394e('0x17')]({'lastMsgAt':_0x3ca317[_0x394e('0x18')],'lastMsgDirection':_0x3ca317[_0x394e('0xf')]['toLowerCase']()});}})[_0x394e('0x19')](function(_0x56f2f1){console['error'](_0x56f2f1);});}if(_0x3ca317['direction']===_0x394e('0x1a')&&!_0x3ca317[_0x394e('0x11')]){var _0x5ecbe5;_0x2e2ac2['WhatsappAccount'][_0x394e('0x1b')]({'where':{'id':_0x3ca317['WhatsappAccountId']},'raw':!![]})[_0x394e('0x16')](function(_0x32b560){_0x5ecbe5=_0x32b560;if(_0x5ecbe5&&_0x5ecbe5[_0x394e('0x1c')]){switch(_0x5ecbe5[_0x394e('0x1c')]){case _0x394e('0x1d'):var _0x45bf89=require(_0x394e('0x1d'));if(_0x5ecbe5['accountSid']&&_0x5ecbe5['authToken']&&_0x5ecbe5[_0x394e('0x1e')]){var _0x25b044=new _0x45bf89(_0x5ecbe5[_0x394e('0x1f')],_0x5ecbe5[_0x394e('0x20')]);_0x25b044[_0x394e('0x21')][_0x394e('0x22')]({'body':_0x3ca317[_0x394e('0xb')],'to':_0x394e('0x23')+_0x3ca317[_0x394e('0x1e')],'from':_0x394e('0x23')+_0x5ecbe5[_0x394e('0x1e')],'statusCallback':_0x5ecbe5[_0x394e('0x24')]+'/api/whatsapp/messages/'+_0x3ca317['id']+_0x394e('0x25')+_0x5ecbe5[_0x394e('0x26')]})[_0x394e('0x16')](function(_0x5a17ea){if(_0x5a17ea['sid']){return _0x54538a['update']({'messageId':_0x5a17ea['sid']});}})[_0x394e('0x19')](function(_0x352436){logger[_0x394e('0x27')](_0x394e('0x28'),_0x394e('0x29'),_0x394e('0x1d'),util[_0x394e('0x2a')](_0x352436,{'showHidden':![],'depth':null}));});}else{logger['error'](_0x394e('0x28'),'afterCreate',_0x394e('0x1d'),_0x394e('0x2b'));}break;}}})[_0x394e('0x2c')](function(){_0x4bd532();});}else{_0x4bd532();}}},'charset':'utf8mb4','collate':_0x394e('0x2d')});};
\ 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