Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / whatsappMessage / whatsappMessage.model.js
index bc918d7..1584f70 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x25f0=['UserId','then','update','catch','error','WhatsappAccount','find','WhatsappAccountId','type','twilio','accountSid','authToken','phone','messages','create','body','whatsapp:','remote','/status?token=','token','sid','afterCreate','inspect','WhatsappMessage,\x20%s,\x20%s,\x20%s','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','/whatsapp/v1/','/messages/','text','POST','Bearer\x20','application/json','statuses','message_id','WhatsappMessage,\x20%s','finally','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','request-promise','node-fetch','rimraf','../../config/environment','./whatsappMessage.attributes','exports','define','whatsapp_messages','messageId','fti_whatsapp_messages','FULLTEXT','direction','toLowerCase','out','isNil'];(function(_0x383fac,_0xeda6b6){var _0x38d3b6=function(_0x481966){while(--_0x481966){_0x383fac['push'](_0x383fac['shift']());}};_0x38d3b6(++_0xeda6b6);}(_0x25f0,0x108));var _0x025f=function(_0x2fc0d8,_0x17a900){_0x2fc0d8=_0x2fc0d8-0x0;var _0x98ec3=_0x25f0[_0x2fc0d8];return _0x98ec3;};'use strict';var _=require(_0x025f('0x0'));var util=require(_0x025f('0x1'));var logger=require(_0x025f('0x2'))(_0x025f('0x3'));var moment=require(_0x025f('0x4'));var BPromise=require(_0x025f('0x5'));var rp=require(_0x025f('0x6'));var fetch=require(_0x025f('0x7'));var fs=require('fs');var path=require('path');var rimraf=require(_0x025f('0x8'));var config=require(_0x025f('0x9'));var attributes=require(_0x025f('0xa'));module[_0x025f('0xb')]=function(_0x357dda,_0x5d74fb){return _0x357dda[_0x025f('0xc')]('WhatsappMessage',attributes,{'tableName':_0x025f('0xd'),'paranoid':![],'indexes':[{'name':_0x025f('0xe'),'fields':[_0x025f('0xe')]},{'name':_0x025f('0xf'),'fields':['body'],'type':_0x025f('0x10')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x1508da,_0x35de33,_0x46b213){var _0x16a5ad=_0x357dda['models'];var _0x2f5ae9=_0x1508da['get']({'plain':!![]});if(_0x2f5ae9[_0x025f('0x11')][_0x025f('0x12')]()==='in'||_0x2f5ae9[_0x025f('0x11')][_0x025f('0x12')]()===_0x025f('0x13')&&!_0x2f5ae9['secret']&&!_[_0x025f('0x14')](_0x2f5ae9[_0x025f('0x15')])){_0x16a5ad['WhatsappInteraction']['findOne']({'where':{'id':_0x2f5ae9['WhatsappInteractionId']}})[_0x025f('0x16')](function(_0x4a7bf2){if(_0x4a7bf2){_0x4a7bf2[_0x025f('0x17')]({'lastMsgAt':_0x2f5ae9['createdAt'],'lastMsgDirection':_0x2f5ae9['direction'][_0x025f('0x12')]()});}})[_0x025f('0x18')](function(_0x47ede3){console[_0x025f('0x19')](_0x47ede3);});}if(_0x2f5ae9[_0x025f('0x11')]==='out'&&!_0x2f5ae9['secret']){var _0x2b2514;_0x16a5ad[_0x025f('0x1a')][_0x025f('0x1b')]({'where':{'id':_0x2f5ae9[_0x025f('0x1c')]},'raw':!![]})[_0x025f('0x16')](function(_0x13b6db){_0x2b2514=_0x13b6db;if(_0x2b2514&&_0x2b2514[_0x025f('0x1d')]){switch(_0x2b2514['type']){case _0x025f('0x1e'):var _0x16b1f6=require(_0x025f('0x1e'));if(_0x2b2514[_0x025f('0x1f')]&&_0x2b2514[_0x025f('0x20')]&&_0x2b2514[_0x025f('0x21')]){var _0x55f9e2=new _0x16b1f6(_0x2b2514[_0x025f('0x1f')],_0x2b2514[_0x025f('0x20')]);_0x55f9e2[_0x025f('0x22')][_0x025f('0x23')]({'body':_0x2f5ae9[_0x025f('0x24')],'to':_0x025f('0x25')+_0x2f5ae9['phone'],'from':_0x025f('0x25')+_0x2b2514[_0x025f('0x21')],'statusCallback':_0x2b2514[_0x025f('0x26')]+'/api/whatsapp/messages/'+_0x2f5ae9['id']+_0x025f('0x27')+_0x2b2514[_0x025f('0x28')]})[_0x025f('0x16')](function(_0x498ebd){if(_0x498ebd[_0x025f('0x29')]){return _0x1508da[_0x025f('0x17')]({'messageId':_0x498ebd[_0x025f('0x29')]});}})['catch'](function(_0x117767){logger['error']('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x025f('0x2a'),_0x025f('0x1e'),util[_0x025f('0x2b')](_0x117767,{'showHidden':![],'depth':null}));});}else{logger[_0x025f('0x19')](_0x025f('0x2c'),_0x025f('0x2a'),'twilio',_0x025f('0x2d'));}break;case'sinch':var _0x1dcbf3=_0x2b2514['accountSid'];var _0x3c761a=_0x2b2514[_0x025f('0x20')];var _0x408caf=_0x2b2514['baseUrl']+_0x025f('0x2e')+_0x1dcbf3+_0x025f('0x2f');var _0x4c28fe={'to':[_0x2f5ae9[_0x025f('0x21')]],'message':{'type':_0x025f('0x30'),'text':_0x2f5ae9[_0x025f('0x24')]}};var _0x4ae657={'method':_0x025f('0x31'),'uri':_0x408caf,'headers':{'Authorization':_0x025f('0x32')+_0x3c761a,'Content-Type':_0x025f('0x33')},'body':_0x4c28fe,'json':!![]};rp(_0x4ae657)[_0x025f('0x16')](function(_0x39a228){if(_0x39a228[_0x025f('0x34')][0x0][_0x025f('0x35')]){return _0x1508da[_0x025f('0x17')]({'messageId':_0x39a228[_0x025f('0x34')][0x0][_0x025f('0x35')]});}})[_0x025f('0x18')](function(_0x2e781a){logger['err'](_0x025f('0x36'),_0x2e781a);});break;}}})[_0x025f('0x37')](function(){_0x46b213();});}else{_0x46b213();}}},'charset':'utf8mb4','collate':_0x025f('0x38')});};
\ No newline at end of file
+var _0x2cd4=['get','direction','toLowerCase','out','secret','WhatsappInteraction','findOne','WhatsappInteractionId','then','update','catch','WhatsappAccount','find','WhatsappAccountId','type','twilio','accountSid','authToken','phone','create','whatsapp:','remote','/api/whatsapp/messages/','/status?token=','sid','inspect','error','afterCreate','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','sinch','baseUrl','/whatsapp/v1/','/messages/','text','POST','Bearer\x20','statuses','message_id','WhatsappMessage,\x20%s','finally','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','api','moment','bluebird','request-promise','node-fetch','path','../../config/environment','define','WhatsappMessage','messageId','fti_whatsapp_messages','body'];(function(_0x37756b,_0x24db76){var _0x46efec=function(_0x319807){while(--_0x319807){_0x37756b['push'](_0x37756b['shift']());}};_0x46efec(++_0x24db76);}(_0x2cd4,0xd2));var _0x42cd=function(_0x1d50f2,_0x3c3ec6){_0x1d50f2=_0x1d50f2-0x0;var _0x3769b8=_0x2cd4[_0x1d50f2];return _0x3769b8;};'use strict';var _=require(_0x42cd('0x0'));var util=require('util');var logger=require(_0x42cd('0x1'))(_0x42cd('0x2'));var moment=require(_0x42cd('0x3'));var BPromise=require(_0x42cd('0x4'));var rp=require(_0x42cd('0x5'));var fetch=require(_0x42cd('0x6'));var fs=require('fs');var path=require(_0x42cd('0x7'));var rimraf=require('rimraf');var config=require(_0x42cd('0x8'));var attributes=require('./whatsappMessage.attributes');module['exports']=function(_0x6bd5af,_0x127bc6){return _0x6bd5af[_0x42cd('0x9')](_0x42cd('0xa'),attributes,{'tableName':'whatsapp_messages','paranoid':![],'indexes':[{'name':_0x42cd('0xb'),'fields':[_0x42cd('0xb')]},{'name':_0x42cd('0xc'),'fields':[_0x42cd('0xd')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x443334,_0x5b6c1d,_0x2c5bc5){var _0x18c683=_0x6bd5af['models'];var _0xa4d83b=_0x443334[_0x42cd('0xe')]({'plain':!![]});if(_0xa4d83b[_0x42cd('0xf')][_0x42cd('0x10')]()==='in'||_0xa4d83b[_0x42cd('0xf')][_0x42cd('0x10')]()===_0x42cd('0x11')&&!_0xa4d83b[_0x42cd('0x12')]&&!_['isNil'](_0xa4d83b['UserId'])){_0x18c683[_0x42cd('0x13')][_0x42cd('0x14')]({'where':{'id':_0xa4d83b[_0x42cd('0x15')]}})[_0x42cd('0x16')](function(_0x7eccb3){if(_0x7eccb3){_0x7eccb3[_0x42cd('0x17')]({'lastMsgAt':_0xa4d83b['createdAt'],'lastMsgDirection':_0xa4d83b['direction'][_0x42cd('0x10')]()});}})[_0x42cd('0x18')](function(_0x4d79c2){console['error'](_0x4d79c2);});}if(_0xa4d83b[_0x42cd('0xf')]===_0x42cd('0x11')&&!_0xa4d83b['secret']){var _0xe21521;_0x18c683[_0x42cd('0x19')][_0x42cd('0x1a')]({'where':{'id':_0xa4d83b[_0x42cd('0x1b')]},'raw':!![]})[_0x42cd('0x16')](function(_0x527c89){_0xe21521=_0x527c89;if(_0xe21521&&_0xe21521['type']){switch(_0xe21521[_0x42cd('0x1c')]){case'twilio':var _0x4cca94=require(_0x42cd('0x1d'));if(_0xe21521[_0x42cd('0x1e')]&&_0xe21521[_0x42cd('0x1f')]&&_0xe21521[_0x42cd('0x20')]){var _0x27ecc1=new _0x4cca94(_0xe21521[_0x42cd('0x1e')],_0xe21521[_0x42cd('0x1f')]);_0x27ecc1['messages'][_0x42cd('0x21')]({'body':_0xa4d83b[_0x42cd('0xd')],'to':_0x42cd('0x22')+_0xa4d83b[_0x42cd('0x20')],'from':_0x42cd('0x22')+_0xe21521['phone'],'statusCallback':_0xe21521[_0x42cd('0x23')]+_0x42cd('0x24')+_0xa4d83b['id']+_0x42cd('0x25')+_0xe21521['token']})[_0x42cd('0x16')](function(_0x4eaa65){if(_0x4eaa65[_0x42cd('0x26')]){return _0x443334['update']({'messageId':_0x4eaa65[_0x42cd('0x26')]});}})[_0x42cd('0x18')](function(_0x3a1c7c){logger['error']('WhatsappMessage,\x20%s,\x20%s,\x20%s','afterCreate',_0x42cd('0x1d'),util[_0x42cd('0x27')](_0x3a1c7c,{'showHidden':![],'depth':null}));});}else{logger[_0x42cd('0x28')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x42cd('0x29'),'twilio',_0x42cd('0x2a'));}break;case _0x42cd('0x2b'):var _0x29d482=_0xe21521['accountSid'];var _0x279b33=_0xe21521[_0x42cd('0x1f')];var _0x2ed177=_0xe21521[_0x42cd('0x2c')]+_0x42cd('0x2d')+_0x29d482+_0x42cd('0x2e');var _0x39bd9d={'to':[_0xa4d83b[_0x42cd('0x20')]],'message':{'type':_0x42cd('0x2f'),'text':_0xa4d83b[_0x42cd('0xd')]}};var _0x202ff1={'method':_0x42cd('0x30'),'uri':_0x2ed177,'headers':{'Authorization':_0x42cd('0x31')+_0x279b33,'Content-Type':'application/json'},'body':_0x39bd9d,'json':!![]};rp(_0x202ff1)['then'](function(_0x3aa6fa){if(_0x3aa6fa[_0x42cd('0x32')][0x0][_0x42cd('0x33')]){return _0x443334[_0x42cd('0x17')]({'messageId':_0x3aa6fa[_0x42cd('0x32')][0x0][_0x42cd('0x33')]});}})['catch'](function(_0x18687d){logger['err'](_0x42cd('0x34'),_0x18687d);});break;}}})[_0x42cd('0x35')](function(){_0x2c5bc5();});}else{_0x2c5bc5();}}},'charset':_0x42cd('0x36'),'collate':_0x42cd('0x37')});};
\ No newline at end of file