Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / whatsappMessage / whatsappMessage.model.js
index 18a46fb..d4329ff 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1be4=['find','then','type','twilio','accountSid','phone','authToken','messages','body','whatsapp:','remote','/api/whatsapp/messages/','/status?token=','token','sid','catch','WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','finally','utf8mb4','utf8mb4_unicode_ci','lodash','moment','bluebird','request-promise','path','rimraf','../../config/environment','./whatsappMessage.attributes','exports','WhatsappMessage','messageId','fti_whatsapp_messages','models','direction','out','secret','isNil','UserId','WhatsappInteraction','findOne','WhatsappInteractionId','update','toLowerCase'];(function(_0x19dd8a,_0x4af545){var _0x6245d3=function(_0x16e70b){while(--_0x16e70b){_0x19dd8a['push'](_0x19dd8a['shift']());}};_0x6245d3(++_0x4af545);}(_0x1be4,0x9d));var _0x41be=function(_0x19a9fa,_0x174540){_0x19a9fa=_0x19a9fa-0x0;var _0x40a47f=_0x1be4[_0x19a9fa];return _0x40a47f;};'use strict';var _=require(_0x41be('0x0'));var util=require('util');var logger=require('../../config/logger')('api');var moment=require(_0x41be('0x1'));var BPromise=require(_0x41be('0x2'));var rp=require(_0x41be('0x3'));var fs=require('fs');var path=require(_0x41be('0x4'));var rimraf=require(_0x41be('0x5'));var config=require(_0x41be('0x6'));var attributes=require(_0x41be('0x7'));module[_0x41be('0x8')]=function(_0xad6431,_0x107e74){return _0xad6431['define'](_0x41be('0x9'),attributes,{'tableName':'whatsapp_messages','paranoid':![],'indexes':[{'name':_0x41be('0xa'),'fields':['messageId']},{'name':_0x41be('0xb'),'fields':['body'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x324963,_0x4ba420,_0xf1da22){var _0x373258=_0xad6431[_0x41be('0xc')];var _0x5780a8=_0x324963['get']({'plain':!![]});if(_0x5780a8[_0x41be('0xd')]['toLowerCase']()==='in'||_0x5780a8[_0x41be('0xd')]['toLowerCase']()===_0x41be('0xe')&&!_0x5780a8[_0x41be('0xf')]&&!_[_0x41be('0x10')](_0x5780a8[_0x41be('0x11')])){_0x373258[_0x41be('0x12')][_0x41be('0x13')]({'where':{'id':_0x5780a8[_0x41be('0x14')]}})['then'](function(_0x5dcee3){if(_0x5dcee3){_0x5dcee3[_0x41be('0x15')]({'lastMsgAt':_0x5780a8['createdAt'],'lastMsgDirection':_0x5780a8[_0x41be('0xd')][_0x41be('0x16')]()});}})['catch'](function(_0x2b126c){console['error'](_0x2b126c);});}if(_0x5780a8['direction']===_0x41be('0xe')&&!_0x5780a8['secret']){var _0x22804f;_0x373258['WhatsappAccount'][_0x41be('0x17')]({'where':{'id':_0x5780a8['WhatsappAccountId']},'raw':!![]})[_0x41be('0x18')](function(_0x2f4660){_0x22804f=_0x2f4660;if(_0x22804f&&_0x22804f['type']){switch(_0x22804f[_0x41be('0x19')]){case _0x41be('0x1a'):var _0x3a6743=require(_0x41be('0x1a'));if(_0x22804f[_0x41be('0x1b')]&&_0x22804f['authToken']&&_0x22804f[_0x41be('0x1c')]){var _0x423e9f=new _0x3a6743(_0x22804f[_0x41be('0x1b')],_0x22804f[_0x41be('0x1d')]);_0x423e9f[_0x41be('0x1e')]['create']({'body':_0x5780a8[_0x41be('0x1f')],'to':'whatsapp:'+_0x5780a8[_0x41be('0x1c')],'from':_0x41be('0x20')+_0x22804f[_0x41be('0x1c')],'statusCallback':_0x22804f[_0x41be('0x21')]+_0x41be('0x22')+_0x5780a8['id']+_0x41be('0x23')+_0x22804f[_0x41be('0x24')]})['then'](function(_0x3b3ac8){if(_0x3b3ac8[_0x41be('0x25')]){return _0x324963[_0x41be('0x15')]({'messageId':_0x3b3ac8[_0x41be('0x25')]});}})[_0x41be('0x26')](function(_0x4ea0ec){logger['error'](_0x41be('0x27'),_0x41be('0x28'),'twilio',util['inspect'](_0x4ea0ec,{'showHidden':![],'depth':null}));});}else{logger['error'](_0x41be('0x27'),_0x41be('0x28'),_0x41be('0x1a'),_0x41be('0x29'));}break;}}})[_0x41be('0x2a')](function(){_0xf1da22();});}else{_0xf1da22();}}},'charset':_0x41be('0x2b'),'collate':_0x41be('0x2c')});};
\ No newline at end of file
+var _0x1db3=['messageId','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','UserId','WhatsappInteraction','WhatsappInteractionId','then','update','createdAt','catch','WhatsappAccount','find','type','twilio','accountSid','authToken','messages','create','whatsapp:','phone','/api/whatsapp/messages/','/status?token=','token','sid','error','WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','inspect','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','finally','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./whatsappMessage.attributes','exports','WhatsappMessage','whatsapp_messages'];(function(_0x5c61af,_0x21aa69){var _0x467143=function(_0x44396a){while(--_0x44396a){_0x5c61af['push'](_0x5c61af['shift']());}};_0x467143(++_0x21aa69);}(_0x1db3,0x15f));var _0x31db=function(_0x56bfd1,_0x283496){_0x56bfd1=_0x56bfd1-0x0;var _0x137b77=_0x1db3[_0x56bfd1];return _0x137b77;};'use strict';var _=require(_0x31db('0x0'));var util=require('util');var logger=require(_0x31db('0x1'))(_0x31db('0x2'));var moment=require(_0x31db('0x3'));var BPromise=require(_0x31db('0x4'));var rp=require(_0x31db('0x5'));var fs=require('fs');var path=require(_0x31db('0x6'));var rimraf=require(_0x31db('0x7'));var config=require(_0x31db('0x8'));var attributes=require(_0x31db('0x9'));module[_0x31db('0xa')]=function(_0xc225bc,_0x2b5ac0){return _0xc225bc['define'](_0x31db('0xb'),attributes,{'tableName':_0x31db('0xc'),'paranoid':![],'indexes':[{'name':_0x31db('0xd'),'fields':[_0x31db('0xd')]},{'name':'fti_whatsapp_messages','fields':[_0x31db('0xe')],'type':_0x31db('0xf')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x38bfdb,_0x14682e,_0x396ee5){var _0x3c3fb9=_0xc225bc[_0x31db('0x10')];var _0xf38317=_0x38bfdb[_0x31db('0x11')]({'plain':!![]});if(_0xf38317[_0x31db('0x12')]['toLowerCase']()==='in'||_0xf38317[_0x31db('0x12')][_0x31db('0x13')]()===_0x31db('0x14')&&!_0xf38317[_0x31db('0x15')]&&!_[_0x31db('0x16')](_0xf38317[_0x31db('0x17')])){_0x3c3fb9[_0x31db('0x18')]['findOne']({'where':{'id':_0xf38317[_0x31db('0x19')]}})[_0x31db('0x1a')](function(_0x33f649){if(_0x33f649){_0x33f649[_0x31db('0x1b')]({'lastMsgAt':_0xf38317[_0x31db('0x1c')],'lastMsgDirection':_0xf38317['direction'][_0x31db('0x13')]()});}})[_0x31db('0x1d')](function(_0x3ca47f){console['error'](_0x3ca47f);});}if(_0xf38317[_0x31db('0x12')]===_0x31db('0x14')&&!_0xf38317[_0x31db('0x15')]){var _0x1123f8;_0x3c3fb9[_0x31db('0x1e')][_0x31db('0x1f')]({'where':{'id':_0xf38317['WhatsappAccountId']},'raw':!![]})['then'](function(_0x12c4ec){_0x1123f8=_0x12c4ec;if(_0x1123f8&&_0x1123f8[_0x31db('0x20')]){switch(_0x1123f8['type']){case'twilio':var _0x8f89af=require(_0x31db('0x21'));if(_0x1123f8[_0x31db('0x22')]&&_0x1123f8[_0x31db('0x23')]&&_0x1123f8['phone']){var _0x4c94f0=new _0x8f89af(_0x1123f8[_0x31db('0x22')],_0x1123f8[_0x31db('0x23')]);_0x4c94f0[_0x31db('0x24')][_0x31db('0x25')]({'body':_0xf38317[_0x31db('0xe')],'to':_0x31db('0x26')+_0xf38317[_0x31db('0x27')],'from':_0x31db('0x26')+_0x1123f8['phone'],'statusCallback':_0x1123f8['remote']+_0x31db('0x28')+_0xf38317['id']+_0x31db('0x29')+_0x1123f8[_0x31db('0x2a')]})[_0x31db('0x1a')](function(_0x25b437){if(_0x25b437[_0x31db('0x2b')]){return _0x38bfdb[_0x31db('0x1b')]({'messageId':_0x25b437['sid']});}})[_0x31db('0x1d')](function(_0x4b8316){logger[_0x31db('0x2c')](_0x31db('0x2d'),_0x31db('0x2e'),'twilio',util[_0x31db('0x2f')](_0x4b8316,{'showHidden':![],'depth':null}));});}else{logger['error'](_0x31db('0x2d'),_0x31db('0x2e'),_0x31db('0x21'),_0x31db('0x30'));}break;}}})[_0x31db('0x31')](function(){_0x396ee5();});}else{_0x396ee5();}}},'charset':_0x31db('0x32'),'collate':_0x31db('0x33')});};
\ No newline at end of file