1c08cf6a198b9e16553943d5662747accfa1f00b
[motion-next.git] / server / api / whatsappMessage / whatsappMessage.options.js
1 const a962_0x619a=['direction','utf8mb4_unicode_ci','utf8mb4','WhatsappInteraction','/api/whatsapp/messages/','find','FULLTEXT','WhatsappAccountId','WhatsappMessage,\x20%s,\x20%s,\x20%s','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','exports','WhatsappInteractionId','authToken','createdAt','lodash','api','create','util','error','inspect','secret','whatsapp_messages','WhatsappAccount','findOne','get','out','messageId','whatsapp:','then','accountSid','token','sid','toLowerCase','update','options','isNil','/status?token=','twilio','type'];(function(_0x1f3dfe,_0x3dffab){const _0x619aff=function(_0x459f15){while(--_0x459f15){_0x1f3dfe['push'](_0x1f3dfe['shift']());}};_0x619aff(++_0x3dffab);}(a962_0x619a,0x6e));const a962_0x459f=function(_0x1f3dfe,_0x3dffab){_0x1f3dfe=_0x1f3dfe-0x11f;let _0x619aff=a962_0x619a[_0x1f3dfe];return _0x619aff;};const a962_0x36959b=a962_0x459f,util=require(a962_0x36959b(0x137)),_=require(a962_0x36959b(0x134)),twilio=require('twilio'),logger=require('../../config/logger')(a962_0x36959b(0x135));function options(_0x119957){const _0x2b6520=a962_0x36959b;return{'sequelize':_0x119957,'tableName':_0x2b6520(0x13b),'paranoid':![],'indexes':[{'name':_0x2b6520(0x140),'fields':['messageId']},{'name':'fti_whatsapp_messages','fields':['body'],'type':_0x2b6520(0x12c)}],'timestamps':!![],'hooks':{'afterCreate':function(_0x30c035){const _0x4d3ae4=_0x2b6520,_0x22b43c=_0x119957['models'],_0x4e9c64=_0x30c035[_0x4d3ae4(0x13e)]({'plain':!![]});(_0x4e9c64['direction'][_0x4d3ae4(0x11f)]()==='in'||_0x4e9c64[_0x4d3ae4(0x126)][_0x4d3ae4(0x11f)]()===_0x4d3ae4(0x13f)&&!_0x4e9c64[_0x4d3ae4(0x13a)]&&!_[_0x4d3ae4(0x122)](_0x4e9c64['UserId']))&&_0x22b43c[_0x4d3ae4(0x129)][_0x4d3ae4(0x13d)]({'where':{'id':_0x4e9c64[_0x4d3ae4(0x131)]}})[_0x4d3ae4(0x142)](function(_0x54604f){const _0x42d9d9=_0x4d3ae4;_0x54604f&&_0x54604f[_0x42d9d9(0x120)]({'lastMsgAt':_0x4e9c64[_0x42d9d9(0x133)],'lastMsgDirection':_0x4e9c64[_0x42d9d9(0x126)]['toLowerCase']()});})['catch'](function(_0x31e7bc){const _0x48f9ef=_0x4d3ae4;console[_0x48f9ef(0x138)](_0x31e7bc);});if(_0x4e9c64[_0x4d3ae4(0x126)]===_0x4d3ae4(0x13f)&&!_0x4e9c64[_0x4d3ae4(0x13a)]){let _0x3afd2f;_0x22b43c[_0x4d3ae4(0x13c)][_0x4d3ae4(0x12b)]({'where':{'id':_0x4e9c64[_0x4d3ae4(0x12d)]},'raw':!![]})['then'](function(_0x33bbc9){const _0x43446f=_0x4d3ae4;_0x3afd2f=_0x33bbc9;if(_0x3afd2f&&_0x3afd2f[_0x43446f(0x125)])switch(_0x3afd2f[_0x43446f(0x125)]){case _0x43446f(0x124):if(_0x3afd2f['accountSid']&&_0x3afd2f[_0x43446f(0x132)]&&_0x3afd2f['phone']){const _0x4be157=new twilio(_0x3afd2f[_0x43446f(0x143)],_0x3afd2f[_0x43446f(0x132)]);_0x4be157['messages'][_0x43446f(0x136)]({'body':_0x4e9c64['body'],'to':_0x43446f(0x141)+_0x4e9c64['phone'],'from':_0x43446f(0x141)+_0x3afd2f['phone'],'statusCallback':_0x3afd2f['remote']+_0x43446f(0x12a)+_0x4e9c64['id']+_0x43446f(0x123)+_0x3afd2f[_0x43446f(0x144)]})[_0x43446f(0x142)](function(_0x2f05d3){const _0x39cb8c=_0x43446f;if(_0x2f05d3[_0x39cb8c(0x145)])return _0x30c035['update']({'messageId':_0x2f05d3[_0x39cb8c(0x145)]});})['catch'](function(_0x5583c3){const _0x130677=_0x43446f;logger[_0x130677(0x138)](_0x130677(0x12e),'afterCreate',_0x130677(0x124),util[_0x130677(0x139)](_0x5583c3,{'showHidden':![],'depth':null}));});}else logger[_0x43446f(0x138)](_0x43446f(0x12e),'afterCreate',_0x43446f(0x124),_0x43446f(0x12f));break;}});}}},'charset':_0x2b6520(0x128),'collate':_0x2b6520(0x127)};}module[a962_0x36959b(0x130)][a962_0x36959b(0x121)]=options;