Built motion from commit (unavailable).|2.5.24
[motion2.git] / server / api / whatsappMessage / whatsappMessage.model.js
index 2cd132a..72e8be1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc9eb=['Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','finally','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','request-promise','path','rimraf','./whatsappMessage.attributes','exports','define','WhatsappMessage','whatsapp_messages','messageId','fti_whatsapp_messages','body','models','get','direction','toLowerCase','out','secret','isNil','UserId','WhatsappInteraction','WhatsappInteractionId','then','update','createdAt','error','WhatsappAccount','find','WhatsappAccountId','type','accountSid','phone','messages','create','whatsapp:','remote','/api/whatsapp/messages/','/status?token=','token','catch','WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','inspect','twilio'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0xc9eb,0xa0));var _0xbc9e=function(_0x557383,_0x227505){_0x557383=_0x557383-0x0;var _0x4afb9c=_0xc9eb[_0x557383];return _0x4afb9c;};'use strict';var _=require(_0xbc9e('0x0'));var util=require(_0xbc9e('0x1'));var logger=require(_0xbc9e('0x2'))(_0xbc9e('0x3'));var moment=require(_0xbc9e('0x4'));var BPromise=require('bluebird');var rp=require(_0xbc9e('0x5'));var fs=require('fs');var path=require(_0xbc9e('0x6'));var rimraf=require(_0xbc9e('0x7'));var config=require('../../config/environment');var attributes=require(_0xbc9e('0x8'));module[_0xbc9e('0x9')]=function(_0x6f3e34,_0x3f26b6){return _0x6f3e34[_0xbc9e('0xa')](_0xbc9e('0xb'),attributes,{'tableName':_0xbc9e('0xc'),'paranoid':![],'indexes':[{'name':'messageId','fields':[_0xbc9e('0xd')]},{'name':_0xbc9e('0xe'),'fields':[_0xbc9e('0xf')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5e7cf5,_0x23d11c,_0xcb034){var _0x1f93dd=_0x6f3e34[_0xbc9e('0x10')];var _0x51a99e=_0x5e7cf5[_0xbc9e('0x11')]({'plain':!![]});if(_0x51a99e[_0xbc9e('0x12')][_0xbc9e('0x13')]()==='in'||_0x51a99e[_0xbc9e('0x12')][_0xbc9e('0x13')]()===_0xbc9e('0x14')&&!_0x51a99e[_0xbc9e('0x15')]&&!_[_0xbc9e('0x16')](_0x51a99e[_0xbc9e('0x17')])){_0x1f93dd[_0xbc9e('0x18')]['findOne']({'where':{'id':_0x51a99e[_0xbc9e('0x19')]}})[_0xbc9e('0x1a')](function(_0xce1056){if(_0xce1056){_0xce1056[_0xbc9e('0x1b')]({'lastMsgAt':_0x51a99e[_0xbc9e('0x1c')],'lastMsgDirection':_0x51a99e['direction'][_0xbc9e('0x13')]()});}})['catch'](function(_0x250513){console[_0xbc9e('0x1d')](_0x250513);});}if(_0x51a99e[_0xbc9e('0x12')]===_0xbc9e('0x14')&&!_0x51a99e[_0xbc9e('0x15')]){var _0x30a765;_0x1f93dd[_0xbc9e('0x1e')][_0xbc9e('0x1f')]({'where':{'id':_0x51a99e[_0xbc9e('0x20')]},'raw':!![]})['then'](function(_0x171c9d){_0x30a765=_0x171c9d;if(_0x30a765&&_0x30a765[_0xbc9e('0x21')]){switch(_0x30a765[_0xbc9e('0x21')]){case'twilio':var _0x2ff552=require('twilio');if(_0x30a765[_0xbc9e('0x22')]&&_0x30a765['authToken']&&_0x30a765[_0xbc9e('0x23')]){var _0x2b6f3f=new _0x2ff552(_0x30a765[_0xbc9e('0x22')],_0x30a765['authToken']);_0x2b6f3f[_0xbc9e('0x24')][_0xbc9e('0x25')]({'body':_0x51a99e[_0xbc9e('0xf')],'to':_0xbc9e('0x26')+_0x51a99e[_0xbc9e('0x23')],'from':'whatsapp:'+_0x30a765[_0xbc9e('0x23')],'statusCallback':_0x30a765[_0xbc9e('0x27')]+_0xbc9e('0x28')+_0x51a99e['id']+_0xbc9e('0x29')+_0x30a765[_0xbc9e('0x2a')]})[_0xbc9e('0x1a')](function(_0x52e2d0){if(_0x52e2d0['sid']){return _0x5e7cf5[_0xbc9e('0x1b')]({'messageId':_0x52e2d0['sid']});}})[_0xbc9e('0x2b')](function(_0x48fc65){logger[_0xbc9e('0x1d')](_0xbc9e('0x2c'),_0xbc9e('0x2d'),'twilio',util[_0xbc9e('0x2e')](_0x48fc65,{'showHidden':![],'depth':null}));});}else{logger[_0xbc9e('0x1d')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0xbc9e('0x2d'),_0xbc9e('0x2f'),_0xbc9e('0x30'));}break;}}})[_0xbc9e('0x31')](function(){_0xcb034();});}else{_0xcb034();}}},'charset':_0xbc9e('0x32'),'collate':_0xbc9e('0x33')});};
\ No newline at end of file
+var _0x3aae=['WhatsappMessage,\x20%s,\x20%s,\x20%s','finally','utf8mb4','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./whatsappMessage.attributes','exports','define','WhatsappMessage','whatsapp_messages','messageId','fti_whatsapp_messages','body','FULLTEXT','toLowerCase','out','secret','isNil','UserId','WhatsappInteraction','findOne','WhatsappInteractionId','then','update','createdAt','direction','error','WhatsappAccount','find','type','twilio','accountSid','phone','authToken','messages','create','whatsapp:','remote','/api/whatsapp/messages/','token','sid','catch','inspect'];(function(_0x4c1991,_0x11a24b){var _0x4fbd4a=function(_0x4f478f){while(--_0x4f478f){_0x4c1991['push'](_0x4c1991['shift']());}};_0x4fbd4a(++_0x11a24b);}(_0x3aae,0x102));var _0xe3aa=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0x3aae[_0xa464c9];return _0x3d73c4;};'use strict';var _=require(_0xe3aa('0x0'));var util=require(_0xe3aa('0x1'));var logger=require(_0xe3aa('0x2'))(_0xe3aa('0x3'));var moment=require(_0xe3aa('0x4'));var BPromise=require(_0xe3aa('0x5'));var rp=require(_0xe3aa('0x6'));var fs=require('fs');var path=require(_0xe3aa('0x7'));var rimraf=require(_0xe3aa('0x8'));var config=require(_0xe3aa('0x9'));var attributes=require(_0xe3aa('0xa'));module[_0xe3aa('0xb')]=function(_0x5426a5,_0xfda58){return _0x5426a5[_0xe3aa('0xc')](_0xe3aa('0xd'),attributes,{'tableName':_0xe3aa('0xe'),'paranoid':![],'indexes':[{'name':_0xe3aa('0xf'),'fields':[_0xe3aa('0xf')]},{'name':_0xe3aa('0x10'),'fields':[_0xe3aa('0x11')],'type':_0xe3aa('0x12')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x421922,_0x46afb4,_0x20d13f){var _0x329352=_0x5426a5['models'];var _0x582ae6=_0x421922['get']({'plain':!![]});if(_0x582ae6['direction']['toLowerCase']()==='in'||_0x582ae6['direction'][_0xe3aa('0x13')]()===_0xe3aa('0x14')&&!_0x582ae6[_0xe3aa('0x15')]&&!_[_0xe3aa('0x16')](_0x582ae6[_0xe3aa('0x17')])){_0x329352[_0xe3aa('0x18')][_0xe3aa('0x19')]({'where':{'id':_0x582ae6[_0xe3aa('0x1a')]}})[_0xe3aa('0x1b')](function(_0x2e09f5){if(_0x2e09f5){_0x2e09f5[_0xe3aa('0x1c')]({'lastMsgAt':_0x582ae6[_0xe3aa('0x1d')],'lastMsgDirection':_0x582ae6[_0xe3aa('0x1e')][_0xe3aa('0x13')]()});}})['catch'](function(_0x22368e){console[_0xe3aa('0x1f')](_0x22368e);});}if(_0x582ae6['direction']==='out'&&!_0x582ae6[_0xe3aa('0x15')]){var _0x14f175;_0x329352[_0xe3aa('0x20')][_0xe3aa('0x21')]({'where':{'id':_0x582ae6['WhatsappAccountId']},'raw':!![]})[_0xe3aa('0x1b')](function(_0x2dd2da){_0x14f175=_0x2dd2da;if(_0x14f175&&_0x14f175[_0xe3aa('0x22')]){switch(_0x14f175['type']){case _0xe3aa('0x23'):var _0x4ea55e=require('twilio');if(_0x14f175[_0xe3aa('0x24')]&&_0x14f175['authToken']&&_0x14f175[_0xe3aa('0x25')]){var _0xf29ddb=new _0x4ea55e(_0x14f175['accountSid'],_0x14f175[_0xe3aa('0x26')]);_0xf29ddb[_0xe3aa('0x27')][_0xe3aa('0x28')]({'body':_0x582ae6[_0xe3aa('0x11')],'to':_0xe3aa('0x29')+_0x582ae6[_0xe3aa('0x25')],'from':_0xe3aa('0x29')+_0x14f175[_0xe3aa('0x25')],'statusCallback':_0x14f175[_0xe3aa('0x2a')]+_0xe3aa('0x2b')+_0x582ae6['id']+'/status?token='+_0x14f175[_0xe3aa('0x2c')]})[_0xe3aa('0x1b')](function(_0x53e4ff){if(_0x53e4ff[_0xe3aa('0x2d')]){return _0x421922['update']({'messageId':_0x53e4ff[_0xe3aa('0x2d')]});}})[_0xe3aa('0x2e')](function(_0xcc9a62){logger[_0xe3aa('0x1f')]('WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate','twilio',util[_0xe3aa('0x2f')](_0xcc9a62,{'showHidden':![],'depth':null}));});}else{logger[_0xe3aa('0x1f')](_0xe3aa('0x30'),'afterCreate',_0xe3aa('0x23'),'Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken');}break;}}})[_0xe3aa('0x31')](function(){_0x20d13f();});}else{_0x20d13f();}}},'charset':_0xe3aa('0x32'),'collate':'utf8mb4_unicode_ci'});};
\ No newline at end of file