Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / whatsappMessage / whatsappMessage.model.js
index 7b151f6..00e3c7a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x014f=['WhatsappAccountId','type','twilio','accountSid','authToken','phone','messages','create','body','whatsapp:','remote','/api/whatsapp/messages/','/status?token=','token','sid','WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','inspect','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','finally','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','bluebird','request-promise','path','../../config/environment','./whatsappMessage.attributes','exports','define','WhatsappMessage','messageId','FULLTEXT','models','get','direction','toLowerCase','out','isNil','WhatsappInteraction','then','update','createdAt','catch','error','secret','WhatsappAccount','find'];(function(_0xbbf4,_0x3035c5){var _0x54fd3a=function(_0x3e0bcc){while(--_0x3e0bcc){_0xbbf4['push'](_0xbbf4['shift']());}};_0x54fd3a(++_0x3035c5);}(_0x014f,0xab));var _0xf014=function(_0x2b4348,_0x58c328){_0x2b4348=_0x2b4348-0x0;var _0x2f7ab3=_0x014f[_0x2b4348];return _0x2f7ab3;};'use strict';var _=require(_0xf014('0x0'));var util=require(_0xf014('0x1'));var logger=require(_0xf014('0x2'))(_0xf014('0x3'));var moment=require('moment');var BPromise=require(_0xf014('0x4'));var rp=require(_0xf014('0x5'));var fs=require('fs');var path=require(_0xf014('0x6'));var rimraf=require('rimraf');var config=require(_0xf014('0x7'));var attributes=require(_0xf014('0x8'));module[_0xf014('0x9')]=function(_0x30f0bf,_0xd8ed37){return _0x30f0bf[_0xf014('0xa')](_0xf014('0xb'),attributes,{'tableName':'whatsapp_messages','paranoid':![],'indexes':[{'name':_0xf014('0xc'),'fields':['messageId']},{'name':'fti_whatsapp_messages','fields':['body'],'type':_0xf014('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5341ab,_0x282d89,_0x5e4fd4){var _0x11b9be=_0x30f0bf[_0xf014('0xe')];var _0x399d2e=_0x5341ab[_0xf014('0xf')]({'plain':!![]});if(_0x399d2e['direction']['toLowerCase']()==='in'||_0x399d2e[_0xf014('0x10')][_0xf014('0x11')]()===_0xf014('0x12')&&!_0x399d2e['secret']&&!_[_0xf014('0x13')](_0x399d2e['UserId'])){_0x11b9be[_0xf014('0x14')]['findOne']({'where':{'id':_0x399d2e['WhatsappInteractionId']}})[_0xf014('0x15')](function(_0x26c4ea){if(_0x26c4ea){_0x26c4ea[_0xf014('0x16')]({'lastMsgAt':_0x399d2e[_0xf014('0x17')],'lastMsgDirection':_0x399d2e['direction'][_0xf014('0x11')]()});}})[_0xf014('0x18')](function(_0x2abf8a){console[_0xf014('0x19')](_0x2abf8a);});}if(_0x399d2e[_0xf014('0x10')]===_0xf014('0x12')&&!_0x399d2e[_0xf014('0x1a')]){var _0x383b80;_0x11b9be[_0xf014('0x1b')][_0xf014('0x1c')]({'where':{'id':_0x399d2e[_0xf014('0x1d')]},'raw':!![]})['then'](function(_0x127e91){_0x383b80=_0x127e91;if(_0x383b80&&_0x383b80[_0xf014('0x1e')]){switch(_0x383b80['type']){case _0xf014('0x1f'):var _0x1a9ac3=require(_0xf014('0x1f'));if(_0x383b80[_0xf014('0x20')]&&_0x383b80[_0xf014('0x21')]&&_0x383b80[_0xf014('0x22')]){var _0x1e6067=new _0x1a9ac3(_0x383b80['accountSid'],_0x383b80['authToken']);_0x1e6067[_0xf014('0x23')][_0xf014('0x24')]({'body':_0x399d2e[_0xf014('0x25')],'to':_0xf014('0x26')+_0x399d2e[_0xf014('0x22')],'from':'whatsapp:'+_0x383b80[_0xf014('0x22')],'statusCallback':_0x383b80[_0xf014('0x27')]+_0xf014('0x28')+_0x399d2e['id']+_0xf014('0x29')+_0x383b80[_0xf014('0x2a')]})['then'](function(_0x50450c){if(_0x50450c[_0xf014('0x2b')]){return _0x5341ab[_0xf014('0x16')]({'messageId':_0x50450c[_0xf014('0x2b')]});}})['catch'](function(_0x55e5f0){logger[_0xf014('0x19')](_0xf014('0x2c'),_0xf014('0x2d'),'twilio',util[_0xf014('0x2e')](_0x55e5f0,{'showHidden':![],'depth':null}));});}else{logger['error']('WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','twilio',_0xf014('0x2f'));}break;}}})[_0xf014('0x30')](function(){_0x5e4fd4();});}else{_0x5e4fd4();}}},'charset':'utf8mb4','collate':_0xf014('0x31')});};
\ No newline at end of file
+var _0x07a3=['whatsapp_messages','messageId','body','FULLTEXT','models','get','direction','out','secret','isNil','UserId','WhatsappInteraction','findOne','then','update','createdAt','toLowerCase','error','WhatsappAccount','WhatsappAccountId','type','twilio','accountSid','authToken','phone','messages','whatsapp:','remote','/status?token=','token','sid','afterCreate','inspect','WhatsappMessage,\x20%s,\x20%s,\x20%s','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','sinch','baseUrl','/whatsapp/v1/','/messages/','text','POST','application/json','statuses','message_id','catch','WhatsappMessage,\x20%s','finally','utf8mb4','utf8mb4_unicode_ci','util','../../config/logger','api','bluebird','request-promise','node-fetch','path','rimraf','../../config/environment','./whatsappMessage.attributes','exports','define','WhatsappMessage'];(function(_0x543084,_0x4337f5){var _0x306a57=function(_0x2769ed){while(--_0x2769ed){_0x543084['push'](_0x543084['shift']());}};_0x306a57(++_0x4337f5);}(_0x07a3,0xeb));var _0x307a=function(_0x4d07cc,_0x587613){_0x4d07cc=_0x4d07cc-0x0;var _0x42de3b=_0x07a3[_0x4d07cc];return _0x42de3b;};'use strict';var _=require('lodash');var util=require(_0x307a('0x0'));var logger=require(_0x307a('0x1'))(_0x307a('0x2'));var moment=require('moment');var BPromise=require(_0x307a('0x3'));var rp=require(_0x307a('0x4'));var fetch=require(_0x307a('0x5'));var fs=require('fs');var path=require(_0x307a('0x6'));var rimraf=require(_0x307a('0x7'));var config=require(_0x307a('0x8'));var attributes=require(_0x307a('0x9'));module[_0x307a('0xa')]=function(_0x348f32,_0x43cf5f){return _0x348f32[_0x307a('0xb')](_0x307a('0xc'),attributes,{'tableName':_0x307a('0xd'),'paranoid':![],'indexes':[{'name':_0x307a('0xe'),'fields':['messageId']},{'name':'fti_whatsapp_messages','fields':[_0x307a('0xf')],'type':_0x307a('0x10')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x3fb534,_0x1a467c,_0x386c98){var _0x3bff09=_0x348f32[_0x307a('0x11')];var _0x47875a=_0x3fb534[_0x307a('0x12')]({'plain':!![]});if(_0x47875a[_0x307a('0x13')]['toLowerCase']()==='in'||_0x47875a[_0x307a('0x13')]['toLowerCase']()===_0x307a('0x14')&&!_0x47875a[_0x307a('0x15')]&&!_[_0x307a('0x16')](_0x47875a[_0x307a('0x17')])){_0x3bff09[_0x307a('0x18')][_0x307a('0x19')]({'where':{'id':_0x47875a['WhatsappInteractionId']}})[_0x307a('0x1a')](function(_0x111349){if(_0x111349){_0x111349[_0x307a('0x1b')]({'lastMsgAt':_0x47875a[_0x307a('0x1c')],'lastMsgDirection':_0x47875a['direction'][_0x307a('0x1d')]()});}})['catch'](function(_0xaa39aa){console[_0x307a('0x1e')](_0xaa39aa);});}if(_0x47875a[_0x307a('0x13')]===_0x307a('0x14')&&!_0x47875a[_0x307a('0x15')]){var _0x2fc219;_0x3bff09[_0x307a('0x1f')]['find']({'where':{'id':_0x47875a[_0x307a('0x20')]},'raw':!![]})[_0x307a('0x1a')](function(_0x56666b){_0x2fc219=_0x56666b;if(_0x2fc219&&_0x2fc219['type']){switch(_0x2fc219[_0x307a('0x21')]){case'twilio':var _0x9a60ee=require(_0x307a('0x22'));if(_0x2fc219[_0x307a('0x23')]&&_0x2fc219[_0x307a('0x24')]&&_0x2fc219[_0x307a('0x25')]){var _0x553d4b=new _0x9a60ee(_0x2fc219[_0x307a('0x23')],_0x2fc219[_0x307a('0x24')]);_0x553d4b[_0x307a('0x26')]['create']({'body':_0x47875a['body'],'to':_0x307a('0x27')+_0x47875a[_0x307a('0x25')],'from':_0x307a('0x27')+_0x2fc219[_0x307a('0x25')],'statusCallback':_0x2fc219[_0x307a('0x28')]+'/api/whatsapp/messages/'+_0x47875a['id']+_0x307a('0x29')+_0x2fc219[_0x307a('0x2a')]})[_0x307a('0x1a')](function(_0x5cefba){if(_0x5cefba[_0x307a('0x2b')]){return _0x3fb534[_0x307a('0x1b')]({'messageId':_0x5cefba[_0x307a('0x2b')]});}})['catch'](function(_0x47a9d6){logger[_0x307a('0x1e')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x307a('0x2c'),'twilio',util[_0x307a('0x2d')](_0x47a9d6,{'showHidden':![],'depth':null}));});}else{logger[_0x307a('0x1e')](_0x307a('0x2e'),_0x307a('0x2c'),_0x307a('0x22'),_0x307a('0x2f'));}break;case _0x307a('0x30'):var _0x3b52ea=_0x2fc219['accountSid'];var _0x4bd1f9=_0x2fc219['authToken'];var _0x106999=_0x2fc219[_0x307a('0x31')]+_0x307a('0x32')+_0x3b52ea+_0x307a('0x33');var _0x4a51c3={'to':[_0x47875a[_0x307a('0x25')]],'message':{'type':_0x307a('0x34'),'text':_0x47875a[_0x307a('0xf')]}};var _0x24f6b9={'method':_0x307a('0x35'),'uri':_0x106999,'headers':{'Authorization':'Bearer\x20'+_0x4bd1f9,'Content-Type':_0x307a('0x36')},'body':_0x4a51c3,'json':!![]};rp(_0x24f6b9)['then'](function(_0xbc6f1e){if(_0xbc6f1e['statuses'][0x0]['message_id']){return _0x3fb534[_0x307a('0x1b')]({'messageId':_0xbc6f1e[_0x307a('0x37')][0x0][_0x307a('0x38')]});}})[_0x307a('0x39')](function(_0x23fa88){logger['err'](_0x307a('0x3a'),_0x23fa88);});break;}}})[_0x307a('0x3b')](function(){_0x386c98();});}else{_0x386c98();}}},'charset':_0x307a('0x3c'),'collate':_0x307a('0x3d')});};
\ No newline at end of file