Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / api / whatsappMessage / whatsappMessage.model.js
index abb007a..0662583 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7f93=['type','twilio','accountSid','authToken','phone','messages','whatsapp:','remote','/status?token=','token','sid','update','error','WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','utf8mb4','lodash','util','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./whatsappMessage.attributes','exports','WhatsappMessage','whatsapp_messages','messageId','body','models','direction','toLowerCase','out','isNil','findOne','WhatsappInteractionId','then','createdAt','catch','secret','WhatsappAccount','WhatsappAccountId'];(function(_0x80a36,_0x259409){var _0x2ea86b=function(_0x27fb74){while(--_0x27fb74){_0x80a36['push'](_0x80a36['shift']());}};_0x2ea86b(++_0x259409);}(_0x7f93,0x1a6));var _0x37f9=function(_0x46308f,_0x2ad2e3){_0x46308f=_0x46308f-0x0;var _0x25f459=_0x7f93[_0x46308f];return _0x25f459;};'use strict';var _=require(_0x37f9('0x0'));var util=require(_0x37f9('0x1'));var logger=require('../../config/logger')(_0x37f9('0x2'));var moment=require(_0x37f9('0x3'));var BPromise=require(_0x37f9('0x4'));var rp=require(_0x37f9('0x5'));var fs=require('fs');var path=require(_0x37f9('0x6'));var rimraf=require(_0x37f9('0x7'));var config=require(_0x37f9('0x8'));var attributes=require(_0x37f9('0x9'));module[_0x37f9('0xa')]=function(_0x17ec48,_0x2b272f){return _0x17ec48['define'](_0x37f9('0xb'),attributes,{'tableName':_0x37f9('0xc'),'paranoid':![],'indexes':[{'name':_0x37f9('0xd'),'fields':[_0x37f9('0xd')]},{'name':'fti_whatsapp_messages','fields':[_0x37f9('0xe')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x4f0de8,_0x1a870d,_0x2d25dc){var _0xe10f2f=_0x17ec48[_0x37f9('0xf')];var _0x4ec147=_0x4f0de8['get']({'plain':!![]});if(_0x4ec147[_0x37f9('0x10')][_0x37f9('0x11')]()==='in'||_0x4ec147[_0x37f9('0x10')][_0x37f9('0x11')]()===_0x37f9('0x12')&&!_0x4ec147['secret']&&!_[_0x37f9('0x13')](_0x4ec147['UserId'])){_0xe10f2f['WhatsappInteraction'][_0x37f9('0x14')]({'where':{'id':_0x4ec147[_0x37f9('0x15')]}})[_0x37f9('0x16')](function(_0xa8c07c){if(_0xa8c07c){_0xa8c07c['update']({'lastMsgAt':_0x4ec147[_0x37f9('0x17')],'lastMsgDirection':_0x4ec147[_0x37f9('0x10')][_0x37f9('0x11')]()});}})[_0x37f9('0x18')](function(_0xeff21e){console['error'](_0xeff21e);});}if(_0x4ec147[_0x37f9('0x10')]==='out'&&!_0x4ec147[_0x37f9('0x19')]){var _0x5430fc;_0xe10f2f[_0x37f9('0x1a')]['find']({'where':{'id':_0x4ec147[_0x37f9('0x1b')]},'raw':!![]})[_0x37f9('0x16')](function(_0xb62622){_0x5430fc=_0xb62622;if(_0x5430fc&&_0x5430fc[_0x37f9('0x1c')]){switch(_0x5430fc[_0x37f9('0x1c')]){case _0x37f9('0x1d'):var _0x50b9ba=require('twilio');if(_0x5430fc[_0x37f9('0x1e')]&&_0x5430fc[_0x37f9('0x1f')]&&_0x5430fc[_0x37f9('0x20')]){var _0x5e1d80=new _0x50b9ba(_0x5430fc['accountSid'],_0x5430fc[_0x37f9('0x1f')]);_0x5e1d80[_0x37f9('0x21')]['create']({'body':_0x4ec147[_0x37f9('0xe')],'to':_0x37f9('0x22')+_0x4ec147[_0x37f9('0x20')],'from':_0x37f9('0x22')+_0x5430fc[_0x37f9('0x20')],'statusCallback':_0x5430fc[_0x37f9('0x23')]+'/api/whatsapp/messages/'+_0x4ec147['id']+_0x37f9('0x24')+_0x5430fc[_0x37f9('0x25')]})[_0x37f9('0x16')](function(_0xa9ac89){if(_0xa9ac89[_0x37f9('0x26')]){return _0x4f0de8[_0x37f9('0x27')]({'messageId':_0xa9ac89[_0x37f9('0x26')]});}})[_0x37f9('0x18')](function(_0x34fc44){logger[_0x37f9('0x28')](_0x37f9('0x29'),'afterCreate','twilio',util['inspect'](_0x34fc44,{'showHidden':![],'depth':null}));});}else{logger[_0x37f9('0x28')](_0x37f9('0x29'),_0x37f9('0x2a'),_0x37f9('0x1d'),_0x37f9('0x2b'));}break;}}})['finally'](function(){_0x2d25dc();});}else{_0x2d25dc();}}},'charset':_0x37f9('0x2c'),'collate':'utf8mb4_unicode_ci'});};
\ No newline at end of file
+var _0xecd8=['bluebird','request-promise','path','define','WhatsappMessage','messageId','fti_whatsapp_messages','FULLTEXT','models','toLowerCase','UserId','WhatsappInteraction','WhatsappInteractionId','then','update','createdAt','catch','direction','out','WhatsappAccount','type','twilio','authToken','phone','accountSid','messages','create','body','/status?token=','sid','error','WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','finally','lodash','../../config/logger','api','moment'];(function(_0x53ccf2,_0x13cb67){var _0x5a2964=function(_0x3b0514){while(--_0x3b0514){_0x53ccf2['push'](_0x53ccf2['shift']());}};_0x5a2964(++_0x13cb67);}(_0xecd8,0x6e));var _0x8ecd=function(_0x228c6d,_0x5d55b4){_0x228c6d=_0x228c6d-0x0;var _0x1385fd=_0xecd8[_0x228c6d];return _0x1385fd;};'use strict';var _=require(_0x8ecd('0x0'));var util=require('util');var logger=require(_0x8ecd('0x1'))(_0x8ecd('0x2'));var moment=require(_0x8ecd('0x3'));var BPromise=require(_0x8ecd('0x4'));var rp=require(_0x8ecd('0x5'));var fs=require('fs');var path=require(_0x8ecd('0x6'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require('./whatsappMessage.attributes');module['exports']=function(_0x2f993e,_0x4a866e){return _0x2f993e[_0x8ecd('0x7')](_0x8ecd('0x8'),attributes,{'tableName':'whatsapp_messages','paranoid':![],'indexes':[{'name':_0x8ecd('0x9'),'fields':[_0x8ecd('0x9')]},{'name':_0x8ecd('0xa'),'fields':['body'],'type':_0x8ecd('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x4188b6,_0x3dda20,_0x238237){var _0x1fbbaf=_0x2f993e[_0x8ecd('0xc')];var _0x22aaa4=_0x4188b6['get']({'plain':!![]});if(_0x22aaa4['direction'][_0x8ecd('0xd')]()==='in'||_0x22aaa4['direction']['toLowerCase']()==='out'&&!_0x22aaa4['secret']&&!_['isNil'](_0x22aaa4[_0x8ecd('0xe')])){_0x1fbbaf[_0x8ecd('0xf')]['findOne']({'where':{'id':_0x22aaa4[_0x8ecd('0x10')]}})[_0x8ecd('0x11')](function(_0x2da8b0){if(_0x2da8b0){_0x2da8b0[_0x8ecd('0x12')]({'lastMsgAt':_0x22aaa4[_0x8ecd('0x13')],'lastMsgDirection':_0x22aaa4['direction'][_0x8ecd('0xd')]()});}})[_0x8ecd('0x14')](function(_0x339f38){console['error'](_0x339f38);});}if(_0x22aaa4[_0x8ecd('0x15')]===_0x8ecd('0x16')&&!_0x22aaa4['secret']){var _0x8c8207;_0x1fbbaf[_0x8ecd('0x17')]['find']({'where':{'id':_0x22aaa4['WhatsappAccountId']},'raw':!![]})[_0x8ecd('0x11')](function(_0x4524d2){_0x8c8207=_0x4524d2;if(_0x8c8207&&_0x8c8207[_0x8ecd('0x18')]){switch(_0x8c8207[_0x8ecd('0x18')]){case _0x8ecd('0x19'):var _0xde580a=require(_0x8ecd('0x19'));if(_0x8c8207['accountSid']&&_0x8c8207[_0x8ecd('0x1a')]&&_0x8c8207[_0x8ecd('0x1b')]){var _0x16e36a=new _0xde580a(_0x8c8207[_0x8ecd('0x1c')],_0x8c8207[_0x8ecd('0x1a')]);_0x16e36a[_0x8ecd('0x1d')][_0x8ecd('0x1e')]({'body':_0x22aaa4[_0x8ecd('0x1f')],'to':'whatsapp:'+_0x22aaa4[_0x8ecd('0x1b')],'from':'whatsapp:'+_0x8c8207[_0x8ecd('0x1b')],'statusCallback':_0x8c8207['remote']+'/api/whatsapp/messages/'+_0x22aaa4['id']+_0x8ecd('0x20')+_0x8c8207['token']})[_0x8ecd('0x11')](function(_0x220329){if(_0x220329[_0x8ecd('0x21')]){return _0x4188b6['update']({'messageId':_0x220329[_0x8ecd('0x21')]});}})['catch'](function(_0x3cfd8d){logger[_0x8ecd('0x22')](_0x8ecd('0x23'),'afterCreate',_0x8ecd('0x19'),util['inspect'](_0x3cfd8d,{'showHidden':![],'depth':null}));});}else{logger[_0x8ecd('0x22')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x8ecd('0x24'),_0x8ecd('0x19'),'Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken');}break;}}})[_0x8ecd('0x25')](function(){_0x238237();});}else{_0x238237();}}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});};
\ No newline at end of file