Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / api / whatsappMessage / whatsappMessage.model.js
index d948a37..0662583 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3d8e=['inspect','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','finally','utf8mb4','lodash','util','../../config/logger','bluebird','request-promise','path','rimraf','./whatsappMessage.attributes','exports','define','WhatsappMessage','whatsapp_messages','messageId','fti_whatsapp_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','UserId','WhatsappInteraction','findOne','WhatsappInteractionId','then','update','catch','error','WhatsappAccount','find','type','twilio','authToken','phone','accountSid','messages','create','whatsapp:','/api/whatsapp/messages/','/status?token=','token','sid','WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate'];(function(_0x457aef,_0x143e7f){var _0x41f664=function(_0x4862f8){while(--_0x4862f8){_0x457aef['push'](_0x457aef['shift']());}};_0x41f664(++_0x143e7f);}(_0x3d8e,0x169));var _0xe3d8=function(_0x10ff4c,_0x35c7e2){_0x10ff4c=_0x10ff4c-0x0;var _0x28bac8=_0x3d8e[_0x10ff4c];return _0x28bac8;};'use strict';var _=require(_0xe3d8('0x0'));var util=require(_0xe3d8('0x1'));var logger=require(_0xe3d8('0x2'))('api');var moment=require('moment');var BPromise=require(_0xe3d8('0x3'));var rp=require(_0xe3d8('0x4'));var fs=require('fs');var path=require(_0xe3d8('0x5'));var rimraf=require(_0xe3d8('0x6'));var config=require('../../config/environment');var attributes=require(_0xe3d8('0x7'));module[_0xe3d8('0x8')]=function(_0xdb5ba8,_0x4cb106){return _0xdb5ba8[_0xe3d8('0x9')](_0xe3d8('0xa'),attributes,{'tableName':_0xe3d8('0xb'),'paranoid':![],'indexes':[{'name':_0xe3d8('0xc'),'fields':[_0xe3d8('0xc')]},{'name':_0xe3d8('0xd'),'fields':[_0xe3d8('0xe')],'type':_0xe3d8('0xf')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x45c645,_0x3ea335,_0xcccc3e){var _0x2b0f4b=_0xdb5ba8[_0xe3d8('0x10')];var _0x4dcf7e=_0x45c645[_0xe3d8('0x11')]({'plain':!![]});if(_0x4dcf7e[_0xe3d8('0x12')][_0xe3d8('0x13')]()==='in'||_0x4dcf7e['direction'][_0xe3d8('0x13')]()===_0xe3d8('0x14')&&!_0x4dcf7e[_0xe3d8('0x15')]&&!_[_0xe3d8('0x16')](_0x4dcf7e[_0xe3d8('0x17')])){_0x2b0f4b[_0xe3d8('0x18')][_0xe3d8('0x19')]({'where':{'id':_0x4dcf7e[_0xe3d8('0x1a')]}})[_0xe3d8('0x1b')](function(_0x7834c1){if(_0x7834c1){_0x7834c1[_0xe3d8('0x1c')]({'lastMsgAt':_0x4dcf7e['createdAt'],'lastMsgDirection':_0x4dcf7e[_0xe3d8('0x12')][_0xe3d8('0x13')]()});}})[_0xe3d8('0x1d')](function(_0x1a96cf){console[_0xe3d8('0x1e')](_0x1a96cf);});}if(_0x4dcf7e[_0xe3d8('0x12')]===_0xe3d8('0x14')&&!_0x4dcf7e['secret']){var _0x583178;_0x2b0f4b[_0xe3d8('0x1f')][_0xe3d8('0x20')]({'where':{'id':_0x4dcf7e['WhatsappAccountId']},'raw':!![]})[_0xe3d8('0x1b')](function(_0x36e5d7){_0x583178=_0x36e5d7;if(_0x583178&&_0x583178['type']){switch(_0x583178[_0xe3d8('0x21')]){case _0xe3d8('0x22'):var _0x5c5473=require('twilio');if(_0x583178['accountSid']&&_0x583178[_0xe3d8('0x23')]&&_0x583178[_0xe3d8('0x24')]){var _0x568c3b=new _0x5c5473(_0x583178[_0xe3d8('0x25')],_0x583178['authToken']);_0x568c3b[_0xe3d8('0x26')][_0xe3d8('0x27')]({'body':_0x4dcf7e[_0xe3d8('0xe')],'to':_0xe3d8('0x28')+_0x4dcf7e[_0xe3d8('0x24')],'from':_0xe3d8('0x28')+_0x583178[_0xe3d8('0x24')],'statusCallback':_0x583178['remote']+_0xe3d8('0x29')+_0x4dcf7e['id']+_0xe3d8('0x2a')+_0x583178[_0xe3d8('0x2b')]})['then'](function(_0x2659f9){if(_0x2659f9[_0xe3d8('0x2c')]){return _0x45c645[_0xe3d8('0x1c')]({'messageId':_0x2659f9[_0xe3d8('0x2c')]});}})[_0xe3d8('0x1d')](function(_0x2c5d75){logger[_0xe3d8('0x1e')](_0xe3d8('0x2d'),_0xe3d8('0x2e'),'twilio',util[_0xe3d8('0x2f')](_0x2c5d75,{'showHidden':![],'depth':null}));});}else{logger[_0xe3d8('0x1e')](_0xe3d8('0x2d'),_0xe3d8('0x2e'),_0xe3d8('0x22'),_0xe3d8('0x30'));}break;}}})[_0xe3d8('0x31')](function(){_0xcccc3e();});}else{_0xcccc3e();}}},'charset':_0xe3d8('0x32'),'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