Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / whatsappMessage / whatsappMessage.model.js
index 8a102ab..6e48c38 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc777=['accountSid','authToken','messages','create','body','phone','whatsapp:','/api/whatsapp/messages/','/status?token=','token','sid','inspect','WhatsappMessage,\x20%s,\x20%s,\x20%s','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','finally','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','moment','rimraf','../../config/environment','./whatsappMessage.attributes','exports','whatsapp_messages','messageId','fti_whatsapp_messages','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','findOne','then','update','createdAt','catch','error','WhatsappAccountId','type','twilio'];(function(_0x15d18f,_0x126b0e){var _0xd12bf7=function(_0x19e661){while(--_0x19e661){_0x15d18f['push'](_0x15d18f['shift']());}};_0xd12bf7(++_0x126b0e);}(_0xc777,0x11f));var _0x7c77=function(_0x189a53,_0x5947d8){_0x189a53=_0x189a53-0x0;var _0xa6844b=_0xc777[_0x189a53];return _0xa6844b;};'use strict';var _=require(_0x7c77('0x0'));var util=require(_0x7c77('0x1'));var logger=require(_0x7c77('0x2'))('api');var moment=require(_0x7c77('0x3'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x7c77('0x4'));var config=require(_0x7c77('0x5'));var attributes=require(_0x7c77('0x6'));module[_0x7c77('0x7')]=function(_0x106cb5,_0x4133d0){return _0x106cb5['define']('WhatsappMessage',attributes,{'tableName':_0x7c77('0x8'),'paranoid':![],'indexes':[{'name':_0x7c77('0x9'),'fields':[_0x7c77('0x9')]},{'name':_0x7c77('0xa'),'fields':['body'],'type':_0x7c77('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x7e3a3f,_0x1b6095,_0x3d1f4f){var _0x31898b=_0x106cb5[_0x7c77('0xc')];var _0x3ac813=_0x7e3a3f[_0x7c77('0xd')]({'plain':!![]});if(_0x3ac813[_0x7c77('0xe')][_0x7c77('0xf')]()==='in'||_0x3ac813[_0x7c77('0xe')][_0x7c77('0xf')]()===_0x7c77('0x10')&&!_0x3ac813[_0x7c77('0x11')]&&!_[_0x7c77('0x12')](_0x3ac813['UserId'])){_0x31898b['WhatsappInteraction'][_0x7c77('0x13')]({'where':{'id':_0x3ac813['WhatsappInteractionId']}})[_0x7c77('0x14')](function(_0x317e30){if(_0x317e30){_0x317e30[_0x7c77('0x15')]({'lastMsgAt':_0x3ac813[_0x7c77('0x16')],'lastMsgDirection':_0x3ac813['direction'][_0x7c77('0xf')]()});}})[_0x7c77('0x17')](function(_0x7a2335){console[_0x7c77('0x18')](_0x7a2335);});}if(_0x3ac813[_0x7c77('0xe')]===_0x7c77('0x10')&&!_0x3ac813[_0x7c77('0x11')]){var _0x41b293;_0x31898b['WhatsappAccount']['find']({'where':{'id':_0x3ac813[_0x7c77('0x19')]},'raw':!![]})[_0x7c77('0x14')](function(_0x24e6d6){_0x41b293=_0x24e6d6;if(_0x41b293&&_0x41b293[_0x7c77('0x1a')]){switch(_0x41b293[_0x7c77('0x1a')]){case _0x7c77('0x1b'):var _0x1f0dee=require(_0x7c77('0x1b'));if(_0x41b293[_0x7c77('0x1c')]&&_0x41b293[_0x7c77('0x1d')]&&_0x41b293['phone']){var _0x35aff6=new _0x1f0dee(_0x41b293[_0x7c77('0x1c')],_0x41b293['authToken']);_0x35aff6[_0x7c77('0x1e')][_0x7c77('0x1f')]({'body':_0x3ac813[_0x7c77('0x20')],'to':'whatsapp:'+_0x3ac813[_0x7c77('0x21')],'from':_0x7c77('0x22')+_0x41b293[_0x7c77('0x21')],'statusCallback':_0x41b293['remote']+_0x7c77('0x23')+_0x3ac813['id']+_0x7c77('0x24')+_0x41b293[_0x7c77('0x25')]})[_0x7c77('0x14')](function(_0x469d0e){if(_0x469d0e[_0x7c77('0x26')]){return _0x7e3a3f[_0x7c77('0x15')]({'messageId':_0x469d0e[_0x7c77('0x26')]});}})[_0x7c77('0x17')](function(_0xdacb87){logger[_0x7c77('0x18')]('WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','twilio',util[_0x7c77('0x27')](_0xdacb87,{'showHidden':![],'depth':null}));});}else{logger['error'](_0x7c77('0x28'),'afterCreate',_0x7c77('0x1b'),_0x7c77('0x29'));}break;}}})[_0x7c77('0x2a')](function(){_0x3d1f4f();});}else{_0x3d1f4f();}}},'charset':_0x7c77('0x2b'),'collate':_0x7c77('0x2c')});};
\ No newline at end of file
+var _0xf7d6=['FULLTEXT','models','get','direction','toLowerCase','isNil','UserId','WhatsappInteraction','WhatsappInteractionId','then','update','createdAt','error','out','secret','find','WhatsappAccountId','type','twilio','authToken','phone','accountSid','messages','remote','/api/whatsapp/messages/','/status?token=','token','sid','WhatsappMessage,\x20%s,\x20%s,\x20%s','inspect','afterCreate','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','finally','utf8mb4','lodash','util','api','bluebird','request-promise','path','rimraf','../../config/environment','exports','whatsapp_messages','messageId','body'];(function(_0x618414,_0x1a7a60){var _0x21c19a=function(_0x507b17){while(--_0x507b17){_0x618414['push'](_0x618414['shift']());}};_0x21c19a(++_0x1a7a60);}(_0xf7d6,0x136));var _0x6f7d=function(_0x501510,_0x61caa9){_0x501510=_0x501510-0x0;var _0x1e6ee5=_0xf7d6[_0x501510];return _0x1e6ee5;};'use strict';var _=require(_0x6f7d('0x0'));var util=require(_0x6f7d('0x1'));var logger=require('../../config/logger')(_0x6f7d('0x2'));var moment=require('moment');var BPromise=require(_0x6f7d('0x3'));var rp=require(_0x6f7d('0x4'));var fs=require('fs');var path=require(_0x6f7d('0x5'));var rimraf=require(_0x6f7d('0x6'));var config=require(_0x6f7d('0x7'));var attributes=require('./whatsappMessage.attributes');module[_0x6f7d('0x8')]=function(_0x45da40,_0x44c0fe){return _0x45da40['define']('WhatsappMessage',attributes,{'tableName':_0x6f7d('0x9'),'paranoid':![],'indexes':[{'name':_0x6f7d('0xa'),'fields':[_0x6f7d('0xa')]},{'name':'fti_whatsapp_messages','fields':[_0x6f7d('0xb')],'type':_0x6f7d('0xc')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x1baf0c,_0x206015,_0x3f7d5a){var _0x449c44=_0x45da40[_0x6f7d('0xd')];var _0x3328a4=_0x1baf0c[_0x6f7d('0xe')]({'plain':!![]});if(_0x3328a4[_0x6f7d('0xf')][_0x6f7d('0x10')]()==='in'||_0x3328a4[_0x6f7d('0xf')][_0x6f7d('0x10')]()==='out'&&!_0x3328a4['secret']&&!_[_0x6f7d('0x11')](_0x3328a4[_0x6f7d('0x12')])){_0x449c44[_0x6f7d('0x13')]['findOne']({'where':{'id':_0x3328a4[_0x6f7d('0x14')]}})[_0x6f7d('0x15')](function(_0x1106e0){if(_0x1106e0){_0x1106e0[_0x6f7d('0x16')]({'lastMsgAt':_0x3328a4[_0x6f7d('0x17')],'lastMsgDirection':_0x3328a4[_0x6f7d('0xf')]['toLowerCase']()});}})['catch'](function(_0x39751c){console[_0x6f7d('0x18')](_0x39751c);});}if(_0x3328a4[_0x6f7d('0xf')]===_0x6f7d('0x19')&&!_0x3328a4[_0x6f7d('0x1a')]){var _0x2dc86b;_0x449c44['WhatsappAccount'][_0x6f7d('0x1b')]({'where':{'id':_0x3328a4[_0x6f7d('0x1c')]},'raw':!![]})['then'](function(_0x58ab7c){_0x2dc86b=_0x58ab7c;if(_0x2dc86b&&_0x2dc86b['type']){switch(_0x2dc86b[_0x6f7d('0x1d')]){case _0x6f7d('0x1e'):var _0xc7c989=require('twilio');if(_0x2dc86b['accountSid']&&_0x2dc86b[_0x6f7d('0x1f')]&&_0x2dc86b[_0x6f7d('0x20')]){var _0x19f769=new _0xc7c989(_0x2dc86b[_0x6f7d('0x21')],_0x2dc86b['authToken']);_0x19f769[_0x6f7d('0x22')]['create']({'body':_0x3328a4[_0x6f7d('0xb')],'to':'whatsapp:'+_0x3328a4['phone'],'from':'whatsapp:'+_0x2dc86b[_0x6f7d('0x20')],'statusCallback':_0x2dc86b[_0x6f7d('0x23')]+_0x6f7d('0x24')+_0x3328a4['id']+_0x6f7d('0x25')+_0x2dc86b[_0x6f7d('0x26')]})['then'](function(_0x4f2a72){if(_0x4f2a72[_0x6f7d('0x27')]){return _0x1baf0c[_0x6f7d('0x16')]({'messageId':_0x4f2a72[_0x6f7d('0x27')]});}})['catch'](function(_0x524d86){logger['error'](_0x6f7d('0x28'),'afterCreate',_0x6f7d('0x1e'),util[_0x6f7d('0x29')](_0x524d86,{'showHidden':![],'depth':null}));});}else{logger[_0x6f7d('0x18')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x6f7d('0x2a'),_0x6f7d('0x1e'),_0x6f7d('0x2b'));}break;}}})[_0x6f7d('0x2c')](function(){_0x3f7d5a();});}else{_0x3f7d5a();}}},'charset':_0x6f7d('0x2d'),'collate':'utf8mb4_unicode_ci'});};
\ No newline at end of file