Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / whatsappMessage / whatsappMessage.controller.js
index 82f43a1..b380640 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5c4c=['twilio','MessageSid','MessageStatus','inspect','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','jayson/promise','client','http','request','then','request\x20sent','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','error','code','WhatsappMessage,\x20%s,\x20%s','message','info','result','catch','status','end','offset','undefined','limit','count','Content-Range','json','apply','reject','save','update','sendStatus','name','send','index','map','WhatsappMessage','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','fields','attributes','length','nolimit','order','sort','filter','where','VIRTUAL','options','findAll','rows','show','params','includeAll','include','merge','find','create','body','destroy','describe','accept','read','readAt','format','UserId','user','get','WhatsappInteraction','WhatsappInteractionId','isNil','read1stAt','YYYY-MM-DD\x20HH:mm:ss','[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','interaction','stringify','null','AcceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','QueryTypes','SELECT','contact','User','agent','internal','manual','interface','SIP/%s','channel','motionChannel','event','EventManager','acceptmessage','whatsapp-interactions','whatsapp','role','RejectMessage','rejectMessage','sequelize','email','rejectmessage','WhatsappAccount','WhatsappAccountId','WhatsppMessage,\x20%s,\x20%s,\x20%s','received\x20delivery\x20report\x20from'];(function(_0x28cbc0,_0x203516){var _0x4b3cf5=function(_0x2a15c6){while(--_0x2a15c6){_0x28cbc0['push'](_0x28cbc0['shift']());}};_0x4b3cf5(++_0x203516);}(_0x5c4c,0x95));var _0xc5c4=function(_0x4e1b38,_0x4440a4){_0x4e1b38=_0x4e1b38-0x0;var _0x15f663=_0x5c4c[_0x4e1b38];return _0x15f663;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xc5c4('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xc5c4('0x1'));var rp=require(_0xc5c4('0x2'));var moment=require(_0xc5c4('0x3'));var BPromise=require(_0xc5c4('0x4'));var Mustache=require('mustache');var util=require(_0xc5c4('0x5'));var path=require(_0xc5c4('0x6'));var sox=require(_0xc5c4('0x7'));var csv=require(_0xc5c4('0x8'));var ejs=require(_0xc5c4('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xc5c4('0xa'));var squel=require(_0xc5c4('0xb'));var crypto=require(_0xc5c4('0xc'));var jsforce=require(_0xc5c4('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xc5c4('0x8'));var querystring=require(_0xc5c4('0xe'));var Papa=require(_0xc5c4('0xf'));var Redis=require(_0xc5c4('0x10'));var authService=require(_0xc5c4('0x11'));var qs=require(_0xc5c4('0x12'));var as=require(_0xc5c4('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xc5c4('0x14'))(_0xc5c4('0x15'));var utils=require(_0xc5c4('0x16'));var config=require(_0xc5c4('0x17'));var licenseUtil=require(_0xc5c4('0x18'));var db=require(_0xc5c4('0x19'))['db'];config[_0xc5c4('0x1a')]=_[_0xc5c4('0x1b')](config[_0xc5c4('0x1a')],{'host':_0xc5c4('0x1c'),'port':0x18eb});var socket=require(_0xc5c4('0x1d'))(new Redis(config[_0xc5c4('0x1a')]));require('./whatsappMessage.socket')[_0xc5c4('0x1e')](socket);var jayson=require(_0xc5c4('0x1f'));var client=jayson[_0xc5c4('0x20')][_0xc5c4('0x21')]({'port':0x232c});var client9002=jayson[_0xc5c4('0x20')][_0xc5c4('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x561cd1,_0x3ea238,_0x11e7e5,_0x5bffcb){return new BPromise(function(_0x8bade0,_0xc78094){var _0x2a10c5=_0x5bffcb||client;return _0x2a10c5[_0xc5c4('0x22')](_0x561cd1,_0x11e7e5)[_0xc5c4('0x23')](function(_0x704105){logger['info']('WhatsappMessage,\x20%s,\x20%s',_0x3ea238,_0xc5c4('0x24'));logger[_0xc5c4('0x25')](_0xc5c4('0x26'),_0x3ea238,'request\x20sent',JSON['stringify'](_0x704105));if(_0x704105[_0xc5c4('0x27')]){if(_0x704105[_0xc5c4('0x27')][_0xc5c4('0x28')]===0x1f4){logger[_0xc5c4('0x27')](_0xc5c4('0x29'),_0x3ea238,_0x704105[_0xc5c4('0x27')]['message']);return _0xc78094(_0x704105[_0xc5c4('0x27')][_0xc5c4('0x2a')]);}logger[_0xc5c4('0x27')]('WhatsappMessage,\x20%s,\x20%s',_0x3ea238,_0x704105[_0xc5c4('0x27')]['message']);return _0x8bade0(_0x704105[_0xc5c4('0x27')][_0xc5c4('0x2a')]);}else{logger[_0xc5c4('0x2b')]('WhatsappMessage,\x20%s,\x20%s',_0x3ea238,_0xc5c4('0x24'));_0x8bade0(_0x704105[_0xc5c4('0x2c')][_0xc5c4('0x2a')]);}})[_0xc5c4('0x2d')](function(_0x5a94cf){logger[_0xc5c4('0x27')](_0xc5c4('0x29'),_0x3ea238,_0x5a94cf);_0xc78094(_0x5a94cf);});});}function respondWithStatusCode(_0x1d9b48,_0xe4a198){_0xe4a198=_0xe4a198||0xcc;return function(_0x5de13d){if(_0x5de13d){return _0x1d9b48['sendStatus'](_0xe4a198);}return _0x1d9b48[_0xc5c4('0x2e')](_0xe4a198)[_0xc5c4('0x2f')]();};}function respondWithResult(_0x616503,_0x47bc30){_0x47bc30=_0x47bc30||0xc8;return function(_0x200557){if(_0x200557){return _0x616503[_0xc5c4('0x2e')](_0x47bc30)['json'](_0x200557);}};}function respondWithFilteredResult(_0x2a20f5,_0x510298){return function(_0x4be3da){if(_0x4be3da){var _0x2d0f23=typeof _0x510298[_0xc5c4('0x30')]===_0xc5c4('0x31')&&typeof _0x510298[_0xc5c4('0x32')]===_0xc5c4('0x31');var _0x9322b8=_0x4be3da[_0xc5c4('0x33')];var _0x5bd54d=_0x2d0f23?0x0:_0x510298[_0xc5c4('0x30')];var _0x5353d5=_0x2d0f23?_0x4be3da['count']:_0x510298[_0xc5c4('0x30')]+_0x510298[_0xc5c4('0x32')];var _0x30e022;if(_0x5353d5>=_0x9322b8){_0x5353d5=_0x9322b8;_0x30e022=0xc8;}else{_0x30e022=0xce;}_0x2a20f5[_0xc5c4('0x2e')](_0x30e022);return _0x2a20f5['set'](_0xc5c4('0x34'),_0x5bd54d+'-'+_0x5353d5+'/'+_0x9322b8)[_0xc5c4('0x35')](_0x4be3da);}return null;};}function patchUpdates(_0x30ab57){return function(_0x53e539){try{jsonpatch[_0xc5c4('0x36')](_0x53e539,_0x30ab57,!![]);}catch(_0x24eeb6){return BPromise[_0xc5c4('0x37')](_0x24eeb6);}return _0x53e539[_0xc5c4('0x38')]();};}function saveUpdates(_0x2c82ba,_0x1a5cf8){return function(_0x1fa67e){if(_0x1fa67e){return _0x1fa67e[_0xc5c4('0x39')](_0x2c82ba)[_0xc5c4('0x23')](function(_0x3c3973){return _0x3c3973;});}return null;};}function removeEntity(_0xc4f431,_0x63ef0d){return function(_0x1a091b){if(_0x1a091b){return _0x1a091b['destroy']()[_0xc5c4('0x23')](function(){_0xc4f431[_0xc5c4('0x2e')](0xcc)[_0xc5c4('0x2f')]();});}};}function handleEntityNotFound(_0x5b223d,_0x818fd9){return function(_0x47d9ec){if(!_0x47d9ec){_0x5b223d[_0xc5c4('0x3a')](0x194);}return _0x47d9ec;};}function handleError(_0xe4a42e,_0x5c2782){_0x5c2782=_0x5c2782||0x1f4;return function(_0x55cceb){logger[_0xc5c4('0x27')](_0x55cceb['stack']);if(_0x55cceb[_0xc5c4('0x3b')]){delete _0x55cceb['name'];}_0xe4a42e[_0xc5c4('0x2e')](_0x5c2782)[_0xc5c4('0x3c')](_0x55cceb);};}exports[_0xc5c4('0x3d')]=function(_0x29ef75,_0x2ec962){var _0x5e856b={},_0x376dbc={},_0x2ea556={'count':0x0,'rows':[]};var _0xfaf586=_[_0xc5c4('0x3e')](db[_0xc5c4('0x3f')][_0xc5c4('0x40')],function(_0x363a97){return{'name':_0x363a97[_0xc5c4('0x41')],'type':_0x363a97[_0xc5c4('0x42')][_0xc5c4('0x43')]};});_0x376dbc['model']=_[_0xc5c4('0x3e')](_0xfaf586,'name');_0x376dbc[_0xc5c4('0x44')]=_[_0xc5c4('0x45')](_0x29ef75[_0xc5c4('0x44')]);_0x376dbc[_0xc5c4('0x46')]=_[_0xc5c4('0x47')](_0x376dbc[_0xc5c4('0x48')],_0x376dbc[_0xc5c4('0x44')]);_0x5e856b['attributes']=_[_0xc5c4('0x47')](_0x376dbc[_0xc5c4('0x48')],qs[_0xc5c4('0x49')](_0x29ef75[_0xc5c4('0x44')][_0xc5c4('0x49')]));_0x5e856b[_0xc5c4('0x4a')]=_0x5e856b['attributes'][_0xc5c4('0x4b')]?_0x5e856b[_0xc5c4('0x4a')]:_0x376dbc['model'];if(!_0x29ef75[_0xc5c4('0x44')]['hasOwnProperty'](_0xc5c4('0x4c'))){_0x5e856b[_0xc5c4('0x32')]=qs[_0xc5c4('0x32')](_0x29ef75[_0xc5c4('0x44')]['limit']);_0x5e856b['offset']=qs[_0xc5c4('0x30')](_0x29ef75[_0xc5c4('0x44')][_0xc5c4('0x30')]);}_0x5e856b[_0xc5c4('0x4d')]=qs[_0xc5c4('0x4e')](_0x29ef75['query'][_0xc5c4('0x4e')]);_0x5e856b['where']=qs[_0xc5c4('0x46')](_['pick'](_0x29ef75['query'],_0x376dbc[_0xc5c4('0x46')]),_0xfaf586);if(_0x29ef75[_0xc5c4('0x44')][_0xc5c4('0x4f')]){_0x5e856b[_0xc5c4('0x50')]=_['merge'](_0x5e856b[_0xc5c4('0x50')],{'$or':_[_0xc5c4('0x3e')](_0xfaf586,function(_0x4e7553){if(_0x4e7553['type']!==_0xc5c4('0x51')){var _0x344e11={};_0x344e11[_0x4e7553[_0xc5c4('0x3b')]]={'$like':'%'+_0x29ef75[_0xc5c4('0x44')][_0xc5c4('0x4f')]+'%'};return _0x344e11;}})});}_0x5e856b=_['merge']({},_0x5e856b,_0x29ef75[_0xc5c4('0x52')]);var _0x3dc226={'where':_0x5e856b['where']};return db[_0xc5c4('0x3f')]['count'](_0x3dc226)[_0xc5c4('0x23')](function(_0x296932){_0x2ea556[_0xc5c4('0x33')]=_0x296932;if(_0x29ef75[_0xc5c4('0x44')]['includeAll']){_0x5e856b['include']=[{'all':!![]}];}return db[_0xc5c4('0x3f')][_0xc5c4('0x53')](_0x5e856b);})[_0xc5c4('0x23')](function(_0x3aafec){_0x2ea556[_0xc5c4('0x54')]=_0x3aafec;return _0x2ea556;})[_0xc5c4('0x23')](respondWithFilteredResult(_0x2ec962,_0x5e856b))['catch'](handleError(_0x2ec962,null));};exports[_0xc5c4('0x55')]=function(_0x258e4a,_0xd08af2){var _0x37efa2={'raw':!![],'where':{'id':_0x258e4a[_0xc5c4('0x56')]['id']}},_0x32d8a2={};_0x32d8a2['model']=_[_0xc5c4('0x45')](db[_0xc5c4('0x3f')][_0xc5c4('0x40')]);_0x32d8a2[_0xc5c4('0x44')]=_[_0xc5c4('0x45')](_0x258e4a[_0xc5c4('0x44')]);_0x32d8a2['filters']=_['intersection'](_0x32d8a2[_0xc5c4('0x48')],_0x32d8a2[_0xc5c4('0x44')]);_0x37efa2['attributes']=_[_0xc5c4('0x47')](_0x32d8a2[_0xc5c4('0x48')],qs[_0xc5c4('0x49')](_0x258e4a[_0xc5c4('0x44')][_0xc5c4('0x49')]));_0x37efa2[_0xc5c4('0x4a')]=_0x37efa2[_0xc5c4('0x4a')][_0xc5c4('0x4b')]?_0x37efa2[_0xc5c4('0x4a')]:_0x32d8a2[_0xc5c4('0x48')];if(_0x258e4a['query'][_0xc5c4('0x57')]){_0x37efa2[_0xc5c4('0x58')]=[{'all':!![]}];}_0x37efa2=_[_0xc5c4('0x59')]({},_0x37efa2,_0x258e4a[_0xc5c4('0x52')]);return db['WhatsappMessage'][_0xc5c4('0x5a')](_0x37efa2)[_0xc5c4('0x23')](handleEntityNotFound(_0xd08af2,null))[_0xc5c4('0x23')](respondWithResult(_0xd08af2,null))[_0xc5c4('0x2d')](handleError(_0xd08af2,null));};exports[_0xc5c4('0x5b')]=function(_0x23a09c,_0x5bd2ef){return db[_0xc5c4('0x3f')][_0xc5c4('0x5b')](_0x23a09c[_0xc5c4('0x5c')],{})[_0xc5c4('0x23')](respondWithResult(_0x5bd2ef,0xc9))[_0xc5c4('0x2d')](handleError(_0x5bd2ef,null));};exports[_0xc5c4('0x39')]=function(_0x4c0523,_0xd7aa4f){if(_0x4c0523[_0xc5c4('0x5c')]['id']){delete _0x4c0523[_0xc5c4('0x5c')]['id'];}return db[_0xc5c4('0x3f')][_0xc5c4('0x5a')]({'where':{'id':_0x4c0523[_0xc5c4('0x56')]['id']}})['then'](handleEntityNotFound(_0xd7aa4f,null))[_0xc5c4('0x23')](saveUpdates(_0x4c0523[_0xc5c4('0x5c')],null))['then'](respondWithResult(_0xd7aa4f,null))[_0xc5c4('0x2d')](handleError(_0xd7aa4f,null));};exports[_0xc5c4('0x5d')]=function(_0x36a4de,_0x581a21){return db[_0xc5c4('0x3f')]['find']({'where':{'id':_0x36a4de[_0xc5c4('0x56')]['id']}})['then'](handleEntityNotFound(_0x581a21,null))[_0xc5c4('0x23')](removeEntity(_0x581a21,null))[_0xc5c4('0x2d')](handleError(_0x581a21,null));};exports[_0xc5c4('0x5e')]=function(_0x3d0b52,_0x33a4ee){return db[_0xc5c4('0x3f')][_0xc5c4('0x5e')]()[_0xc5c4('0x23')](respondWithResult(_0x33a4ee,null))[_0xc5c4('0x2d')](handleError(_0x33a4ee,null));};var interaction_log=require(_0xc5c4('0x14'))('whatsapp-interactions');exports[_0xc5c4('0x5f')]=function(_0x15963d,_0x1a2908,_0x21a96b){var _0x4269b6={'agent':{},'channel':'whatsapp'};if(_0x15963d[_0xc5c4('0x5c')]['id']){delete _0x15963d[_0xc5c4('0x5c')]['id'];}_0x15963d[_0xc5c4('0x5c')][_0xc5c4('0x60')]=!![];_0x15963d[_0xc5c4('0x5c')][_0xc5c4('0x61')]=moment()[_0xc5c4('0x62')]('YYYY-MM-DD\x20HH:mm:ss');_0x15963d[_0xc5c4('0x5c')][_0xc5c4('0x63')]=_0x15963d[_0xc5c4('0x5c')][_0xc5c4('0x63')]||_0x15963d[_0xc5c4('0x64')]['id'];_0x4269b6['agent']['id']=_0x15963d[_0xc5c4('0x5c')][_0xc5c4('0x63')];return db[_0xc5c4('0x3f')][_0xc5c4('0x5a')]({'where':{'id':_0x15963d[_0xc5c4('0x56')]['id'],'UserId':null}})[_0xc5c4('0x23')](handleEntityNotFound(_0x1a2908,null))[_0xc5c4('0x23')](saveUpdates(_0x15963d[_0xc5c4('0x5c')],null))[_0xc5c4('0x23')](function(_0x250cf6){if(_0x250cf6){_0x4269b6[_0xc5c4('0x2a')]=_0x250cf6[_0xc5c4('0x65')]({'plain':!![]});return db[_0xc5c4('0x66')]['find']({'where':{'id':_0x250cf6[_0xc5c4('0x67')]}});}return null;})['then'](handleEntityNotFound(_0x1a2908,null))[_0xc5c4('0x23')](function(_0x4f3960){if(_0x4f3960){return _0x4f3960['update']({'UserId':_0x15963d['body'][_0xc5c4('0x63')],'read1stAt':_[_0xc5c4('0x68')](_0x4f3960[_0xc5c4('0x69')])?moment()[_0xc5c4('0x62')](_0xc5c4('0x6a')):undefined});}return null;})['then'](function(_0x3e64f9){if(_0x3e64f9){_0x4269b6['interaction']=_0x3e64f9[_0xc5c4('0x65')]({'plain':!![]});interaction_log[_0xc5c4('0x2b')](_0xc5c4('0x6b'),_0x15963d[_0xc5c4('0x64')]['id'],_0x15963d[_0xc5c4('0x64')]['name'],_0x15963d[_0xc5c4('0x64')]['role'],_0x4269b6[_0xc5c4('0x6c')]['id'],_0x15963d[_0xc5c4('0x5c')]?JSON[_0xc5c4('0x6d')](_0x15963d[_0xc5c4('0x5c')]):_0xc5c4('0x6e'));return respondWithRpcPromise(_0xc5c4('0x6f'),'acceptMessage',_0x4269b6);}return null;})[_0xc5c4('0x23')](function(_0x3fee0e){var _0x46d402=_0xc5c4('0x70')+_0x3fee0e[_0xc5c4('0x2a')][_0xc5c4('0x71')];return db['sequelize'][_0xc5c4('0x44')](_0x46d402,{'type':db[_0xc5c4('0x72')][_0xc5c4('0x73')][_0xc5c4('0x74')],'raw':!![]})[_0xc5c4('0x23')](function(_0x301cba){return _0x301cba;});})[_0xc5c4('0x23')](function(_0x24f974){if(_0x24f974){_0x4269b6['message'][_0xc5c4('0x75')]=_0x24f974[0x0];if(!_0x15963d['body'][_0xc5c4('0x63')])return;return db[_0xc5c4('0x76')][_0xc5c4('0x5a')]({'where':{'id':_0x15963d[_0xc5c4('0x5c')]['UserId'],'role':_0xc5c4('0x77')},'attributes':['id',_0xc5c4('0x3b'),'fullname','email',_0xc5c4('0x78')],'raw':!![]});}return null;})['then'](function(_0x2669f3){if(!_0x2669f3)return null;_0x4269b6[_0xc5c4('0x2a')]['agent']=_0x2669f3;return _0x4269b6;})[_0xc5c4('0x23')](function(_0x5910aa){if(_0x5910aa){if(_0x15963d[_0xc5c4('0x5c')][_0xc5c4('0x79')]){_0x4269b6[_0xc5c4('0x2a')][_0xc5c4('0x7a')]=util[_0xc5c4('0x62')](_0xc5c4('0x7b'),_0x15963d[_0xc5c4('0x64')]['name']);_0x4269b6[_0xc5c4('0x2a')][_0xc5c4('0x7c')]=_0x4269b6[_0xc5c4('0x7c')];_0x4269b6[_0xc5c4('0x2a')][_0xc5c4('0x7d')]=_0x4269b6['channel'];_0x4269b6[_0xc5c4('0x2a')][_0xc5c4('0x7e')]=_0xc5c4('0x5f');return respondWithRpcPromise(_0xc5c4('0x7f'),_0xc5c4('0x7f'),{'event':_0xc5c4('0x80'),'message':_0x4269b6[_0xc5c4('0x2a')]},client9002)[_0xc5c4('0x23')](function(){return _0x4269b6;});}return _0x4269b6;}return null;})[_0xc5c4('0x23')](respondWithResult(_0x1a2908,null))[_0xc5c4('0x2d')](handleError(_0x1a2908,null));};var interaction_log=require('../../config/logger')(_0xc5c4('0x81'));exports[_0xc5c4('0x37')]=function(_0x5ee023,_0x411f21,_0x5371b8){var _0x4e6549={'agent':{},'channel':_0xc5c4('0x82')};if(_0x5ee023[_0xc5c4('0x5c')]['id']){delete _0x5ee023[_0xc5c4('0x5c')]['id'];}_0x5ee023[_0xc5c4('0x5c')][_0xc5c4('0x63')]=_0x5ee023[_0xc5c4('0x5c')]['UserId']||_0x5ee023[_0xc5c4('0x64')]['id'];_0x4e6549['agent']['id']=_0x5ee023['body'][_0xc5c4('0x63')];return db[_0xc5c4('0x3f')]['find']({'where':{'id':_0x5ee023[_0xc5c4('0x56')]['id'],'UserId':null}})[_0xc5c4('0x23')](handleEntityNotFound(_0x411f21,null))[_0xc5c4('0x23')](function(_0x989f81){if(_0x989f81){_0x4e6549['message']=_0x989f81[_0xc5c4('0x65')]({'plain':!![]});return db[_0xc5c4('0x66')][_0xc5c4('0x5a')]({'where':{'id':_0x989f81[_0xc5c4('0x67')]}});}return null;})[_0xc5c4('0x23')](handleEntityNotFound(_0x411f21,null))[_0xc5c4('0x23')](function(_0x18fc1c){if(_0x18fc1c){_0x4e6549['interaction']=_0x18fc1c['get']({'plain':!![]});interaction_log[_0xc5c4('0x2b')]('[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x5ee023[_0xc5c4('0x64')]['id'],_0x5ee023[_0xc5c4('0x64')][_0xc5c4('0x3b')],_0x5ee023['user'][_0xc5c4('0x83')],_0x4e6549[_0xc5c4('0x6c')]['id'],_0x5ee023[_0xc5c4('0x5c')]?JSON[_0xc5c4('0x6d')](_0x5ee023[_0xc5c4('0x5c')]):_0xc5c4('0x6e'));return respondWithRpcPromise(_0xc5c4('0x84'),_0xc5c4('0x85'),_0x4e6549);}return null;})[_0xc5c4('0x23')](function(_0x2684aa){var _0x22fa4c=_0xc5c4('0x70')+_0x2684aa[_0xc5c4('0x2a')][_0xc5c4('0x71')];return db[_0xc5c4('0x86')][_0xc5c4('0x44')](_0x22fa4c,{'type':db[_0xc5c4('0x72')][_0xc5c4('0x73')]['SELECT'],'raw':!![]})[_0xc5c4('0x23')](function(_0x4bfeec){return _0x4bfeec;});})[_0xc5c4('0x23')](function(_0xfffde0){if(_0xfffde0){_0x4e6549['message'][_0xc5c4('0x75')]=_0xfffde0[0x0];if(!_0x5ee023[_0xc5c4('0x5c')][_0xc5c4('0x63')])return;return db['User']['find']({'where':{'id':_0x5ee023['body'][_0xc5c4('0x63')],'role':'agent'},'attributes':['id','name','fullname',_0xc5c4('0x87'),'internal'],'raw':!![]});}return null;})[_0xc5c4('0x23')](function(_0x50d6d3){if(!_0x50d6d3)return null;_0x4e6549[_0xc5c4('0x2a')][_0xc5c4('0x77')]=_0x50d6d3;return _0x4e6549;})[_0xc5c4('0x23')](function(_0x35c7c6){if(_0x35c7c6){_0x35c7c6[_0xc5c4('0x2a')][_0xc5c4('0x7a')]=util[_0xc5c4('0x62')](_0xc5c4('0x7b'),_0x5ee023[_0xc5c4('0x64')][_0xc5c4('0x3b')]);_0x35c7c6[_0xc5c4('0x2a')][_0xc5c4('0x7c')]=_0x4e6549[_0xc5c4('0x7c')];_0x35c7c6[_0xc5c4('0x2a')][_0xc5c4('0x7d')]=_0x4e6549['channel'];_0x35c7c6['message'][_0xc5c4('0x7e')]=_0xc5c4('0x37');respondWithRpcPromise(_0xc5c4('0x7f'),'EventManager',{'event':_0xc5c4('0x88'),'message':_0x35c7c6[_0xc5c4('0x2a')]},client9002);return _0x4e6549;}return null;})[_0xc5c4('0x23')](respondWithResult(_0x411f21,null))[_0xc5c4('0x2d')](handleError(_0x411f21,null));};exports[_0xc5c4('0x2e')]=function(_0x4f129e,_0x5246ba,_0x4e1c0f){if(_0x4f129e[_0xc5c4('0x5c')]['id']){delete _0x4f129e[_0xc5c4('0x5c')]['id'];}var _0x3331ba;return db[_0xc5c4('0x3f')][_0xc5c4('0x5a')]({'where':{'id':_0x4f129e[_0xc5c4('0x56')]['id']}})['then'](handleEntityNotFound(_0x5246ba,null))[_0xc5c4('0x23')](function(_0x135910){if(_0x135910){_0x3331ba=_0x135910;return db[_0xc5c4('0x89')][_0xc5c4('0x5a')]({'where':{'id':_0x135910[_0xc5c4('0x8a')]}});}})[_0xc5c4('0x23')](handleEntityNotFound(_0x5246ba,null))['then'](function(_0x3bddea){if(_0x3bddea){logger[_0xc5c4('0x25')](_0xc5c4('0x8b'),'status',_0xc5c4('0x8c'),_0x3bddea['type'],util['inspect'](_0x4f129e[_0xc5c4('0x5c')],{'showHidden':![],'depth':null}));switch(_0x3bddea[_0xc5c4('0x42')]){case _0xc5c4('0x8d'):if(_0x4f129e[_0xc5c4('0x5c')][_0xc5c4('0x8e')]&&_0x4f129e[_0xc5c4('0x5c')][_0xc5c4('0x8e')]===_0x3331ba['messageId']&&_0x4f129e['body'][_0xc5c4('0x8f')]&&_0x4f129e[_0xc5c4('0x5c')][_0xc5c4('0x8f')]===_0xc5c4('0x60')){return _0x3331ba[_0xc5c4('0x39')]({'read':!![]});}else{logger[_0xc5c4('0x27')]('WhatsappAccount,\x20%s,\x20%s,\x20%s',_0xc5c4('0x2e'),_0xc5c4('0x8d'),util[_0xc5c4('0x90')](_0x4f129e['body'],{'showHidden':![],'depth':null}));}break;}return _0x3331ba;}})[_0xc5c4('0x23')](respondWithResult(_0x5246ba,null))[_0xc5c4('0x2d')](handleError(_0x5246ba,null));};
\ No newline at end of file
+var _0xf0c0=['WhatsappMessage','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','sort','where','filter','merge','map','VIRTUAL','includeAll','include','rows','show','params','find','create','update','describe','whatsapp-interactions','accept','whatsapp','body','read','readAt','format','UserId','agent','get','WhatsappInteractionId','read1stAt','YYYY-MM-DD\x20HH:mm:ss','interaction','info','[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','null','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','QueryTypes','SELECT','User','fullname','email','internal','manual','interface','channel','motionChannel','event','EventManager','[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','contact','SIP/%s','WhatsappAccount','WhatsppMessage,\x20%s,\x20%s,\x20%s','received\x20delivery\x20report\x20from','inspect','twilio','MessageSid','messageId','MessageStatus','WhatsappAccount,\x20%s,\x20%s,\x20%s','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','register','jayson/promise','client','http','WhatsappMessage,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','sendStatus','status','offset','undefined','count','limit','set','json','apply','reject','save','then','destroy','stack','name','index'];(function(_0x50ad29,_0x462032){var _0xeb08b2=function(_0x4446d2){while(--_0x4446d2){_0x50ad29['push'](_0x50ad29['shift']());}};_0xeb08b2(++_0x462032);}(_0xf0c0,0x158));var _0x0f0c=function(_0x3ea86e,_0x4ce7ed){_0x3ea86e=_0x3ea86e-0x0;var _0x3de213=_0xf0c0[_0x3ea86e];return _0x3de213;};'use strict';var emlformat=require(_0x0f0c('0x0'));var rimraf=require(_0x0f0c('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0f0c('0x2'));var rp=require(_0x0f0c('0x3'));var moment=require(_0x0f0c('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x0f0c('0x5'));var util=require(_0x0f0c('0x6'));var path=require(_0x0f0c('0x7'));var sox=require('sox');var csv=require(_0x0f0c('0x8'));var ejs=require(_0x0f0c('0x9'));var fs=require('fs');var fs_extra=require(_0x0f0c('0xa'));var _=require(_0x0f0c('0xb'));var squel=require(_0x0f0c('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0f0c('0xd'));var toCsv=require(_0x0f0c('0x8'));var querystring=require(_0x0f0c('0xe'));var Papa=require(_0x0f0c('0xf'));var Redis=require('ioredis');var authService=require(_0x0f0c('0x10'));var qs=require(_0x0f0c('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x0f0c('0x12'))(_0x0f0c('0x13'));var utils=require(_0x0f0c('0x14'));var config=require(_0x0f0c('0x15'));var licenseUtil=require(_0x0f0c('0x16'));var db=require(_0x0f0c('0x17'))['db'];config[_0x0f0c('0x18')]=_[_0x0f0c('0x19')](config[_0x0f0c('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0x0f0c('0x1a'))(new Redis(config['redis']));require('./whatsappMessage.socket')[_0x0f0c('0x1b')](socket);var jayson=require(_0x0f0c('0x1c'));var client=jayson[_0x0f0c('0x1d')][_0x0f0c('0x1e')]({'port':0x232c});var client9002=jayson[_0x0f0c('0x1d')][_0x0f0c('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x46d417,_0x14a3f5,_0x20bb80,_0x56d67f){return new BPromise(function(_0x2ecd0e,_0x3350be){var _0x35b274=_0x56d67f||client;return _0x35b274['request'](_0x46d417,_0x20bb80)['then'](function(_0x4264a0){logger['info'](_0x0f0c('0x1f'),_0x14a3f5,'request\x20sent');logger['debug']('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x14a3f5,_0x0f0c('0x20'),JSON[_0x0f0c('0x21')](_0x4264a0));if(_0x4264a0['error']){if(_0x4264a0[_0x0f0c('0x22')][_0x0f0c('0x23')]===0x1f4){logger[_0x0f0c('0x22')]('WhatsappMessage,\x20%s,\x20%s',_0x14a3f5,_0x4264a0[_0x0f0c('0x22')]['message']);return _0x3350be(_0x4264a0[_0x0f0c('0x22')]['message']);}logger[_0x0f0c('0x22')](_0x0f0c('0x1f'),_0x14a3f5,_0x4264a0[_0x0f0c('0x22')]['message']);return _0x2ecd0e(_0x4264a0[_0x0f0c('0x22')][_0x0f0c('0x24')]);}else{logger['info']('WhatsappMessage,\x20%s,\x20%s',_0x14a3f5,_0x0f0c('0x20'));_0x2ecd0e(_0x4264a0[_0x0f0c('0x25')][_0x0f0c('0x24')]);}})[_0x0f0c('0x26')](function(_0x28f022){logger[_0x0f0c('0x22')](_0x0f0c('0x1f'),_0x14a3f5,_0x28f022);_0x3350be(_0x28f022);});});}function respondWithStatusCode(_0xd128fe,_0x256f52){_0x256f52=_0x256f52||0xcc;return function(_0x3939d5){if(_0x3939d5){return _0xd128fe[_0x0f0c('0x27')](_0x256f52);}return _0xd128fe[_0x0f0c('0x28')](_0x256f52)['end']();};}function respondWithResult(_0x3e9086,_0x3a155e){_0x3a155e=_0x3a155e||0xc8;return function(_0x44c238){if(_0x44c238){return _0x3e9086[_0x0f0c('0x28')](_0x3a155e)['json'](_0x44c238);}};}function respondWithFilteredResult(_0x5092b3,_0x20ab0c){return function(_0x584f17){if(_0x584f17){var _0x43d342=typeof _0x20ab0c[_0x0f0c('0x29')]==='undefined'&&typeof _0x20ab0c['limit']===_0x0f0c('0x2a');var _0x1a7feb=_0x584f17['count'];var _0x521a27=_0x43d342?0x0:_0x20ab0c[_0x0f0c('0x29')];var _0x1246d7=_0x43d342?_0x584f17[_0x0f0c('0x2b')]:_0x20ab0c[_0x0f0c('0x29')]+_0x20ab0c[_0x0f0c('0x2c')];var _0x4bdee3;if(_0x1246d7>=_0x1a7feb){_0x1246d7=_0x1a7feb;_0x4bdee3=0xc8;}else{_0x4bdee3=0xce;}_0x5092b3[_0x0f0c('0x28')](_0x4bdee3);return _0x5092b3[_0x0f0c('0x2d')]('Content-Range',_0x521a27+'-'+_0x1246d7+'/'+_0x1a7feb)[_0x0f0c('0x2e')](_0x584f17);}return null;};}function patchUpdates(_0x2ada84){return function(_0x27f872){try{jsonpatch[_0x0f0c('0x2f')](_0x27f872,_0x2ada84,!![]);}catch(_0x44093b){return BPromise[_0x0f0c('0x30')](_0x44093b);}return _0x27f872[_0x0f0c('0x31')]();};}function saveUpdates(_0x433bab,_0x59342d){return function(_0x131352){if(_0x131352){return _0x131352['update'](_0x433bab)[_0x0f0c('0x32')](function(_0x5e05f7){return _0x5e05f7;});}return null;};}function removeEntity(_0x4b9c7e,_0x3e67d0){return function(_0x21161f){if(_0x21161f){return _0x21161f[_0x0f0c('0x33')]()[_0x0f0c('0x32')](function(){_0x4b9c7e['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x92c276,_0x27e472){return function(_0x209914){if(!_0x209914){_0x92c276[_0x0f0c('0x27')](0x194);}return _0x209914;};}function handleError(_0xbada47,_0x48a344){_0x48a344=_0x48a344||0x1f4;return function(_0x2817ff){logger[_0x0f0c('0x22')](_0x2817ff[_0x0f0c('0x34')]);if(_0x2817ff[_0x0f0c('0x35')]){delete _0x2817ff['name'];}_0xbada47['status'](_0x48a344)['send'](_0x2817ff);};}exports[_0x0f0c('0x36')]=function(_0x1f646a,_0x627c1){var _0x351ec2={},_0x30ed68={},_0x17bff9={'count':0x0,'rows':[]};var _0x145473=_['map'](db[_0x0f0c('0x37')][_0x0f0c('0x38')],function(_0x430c10){return{'name':_0x430c10[_0x0f0c('0x39')],'type':_0x430c10[_0x0f0c('0x3a')][_0x0f0c('0x3b')]};});_0x30ed68[_0x0f0c('0x3c')]=_['map'](_0x145473,_0x0f0c('0x35'));_0x30ed68['query']=_[_0x0f0c('0x3d')](_0x1f646a[_0x0f0c('0x3e')]);_0x30ed68[_0x0f0c('0x3f')]=_['intersection'](_0x30ed68[_0x0f0c('0x3c')],_0x30ed68[_0x0f0c('0x3e')]);_0x351ec2[_0x0f0c('0x40')]=_[_0x0f0c('0x41')](_0x30ed68['model'],qs[_0x0f0c('0x42')](_0x1f646a['query']['fields']));_0x351ec2[_0x0f0c('0x40')]=_0x351ec2['attributes'][_0x0f0c('0x43')]?_0x351ec2[_0x0f0c('0x40')]:_0x30ed68[_0x0f0c('0x3c')];if(!_0x1f646a[_0x0f0c('0x3e')][_0x0f0c('0x44')]('nolimit')){_0x351ec2[_0x0f0c('0x2c')]=qs[_0x0f0c('0x2c')](_0x1f646a[_0x0f0c('0x3e')][_0x0f0c('0x2c')]);_0x351ec2[_0x0f0c('0x29')]=qs[_0x0f0c('0x29')](_0x1f646a[_0x0f0c('0x3e')][_0x0f0c('0x29')]);}_0x351ec2['order']=qs[_0x0f0c('0x45')](_0x1f646a['query'][_0x0f0c('0x45')]);_0x351ec2[_0x0f0c('0x46')]=qs[_0x0f0c('0x3f')](_['pick'](_0x1f646a[_0x0f0c('0x3e')],_0x30ed68[_0x0f0c('0x3f')]),_0x145473);if(_0x1f646a[_0x0f0c('0x3e')][_0x0f0c('0x47')]){_0x351ec2[_0x0f0c('0x46')]=_[_0x0f0c('0x48')](_0x351ec2[_0x0f0c('0x46')],{'$or':_[_0x0f0c('0x49')](_0x145473,function(_0x5167f1){if(_0x5167f1[_0x0f0c('0x3a')]!==_0x0f0c('0x4a')){var _0x11dd44={};_0x11dd44[_0x5167f1[_0x0f0c('0x35')]]={'$like':'%'+_0x1f646a[_0x0f0c('0x3e')][_0x0f0c('0x47')]+'%'};return _0x11dd44;}})});}_0x351ec2=_[_0x0f0c('0x48')]({},_0x351ec2,_0x1f646a['options']);var _0x2bb6cc={'where':_0x351ec2[_0x0f0c('0x46')]};return db[_0x0f0c('0x37')][_0x0f0c('0x2b')](_0x2bb6cc)[_0x0f0c('0x32')](function(_0x5de5ca){_0x17bff9[_0x0f0c('0x2b')]=_0x5de5ca;if(_0x1f646a['query'][_0x0f0c('0x4b')]){_0x351ec2[_0x0f0c('0x4c')]=[{'all':!![]}];}return db[_0x0f0c('0x37')]['findAll'](_0x351ec2);})[_0x0f0c('0x32')](function(_0x3529fb){_0x17bff9[_0x0f0c('0x4d')]=_0x3529fb;return _0x17bff9;})[_0x0f0c('0x32')](respondWithFilteredResult(_0x627c1,_0x351ec2))[_0x0f0c('0x26')](handleError(_0x627c1,null));};exports[_0x0f0c('0x4e')]=function(_0x3e8b2d,_0xf60093){var _0x109827={'raw':!![],'where':{'id':_0x3e8b2d[_0x0f0c('0x4f')]['id']}},_0x426c58={};_0x426c58['model']=_[_0x0f0c('0x3d')](db[_0x0f0c('0x37')][_0x0f0c('0x38')]);_0x426c58['query']=_[_0x0f0c('0x3d')](_0x3e8b2d[_0x0f0c('0x3e')]);_0x426c58[_0x0f0c('0x3f')]=_['intersection'](_0x426c58[_0x0f0c('0x3c')],_0x426c58['query']);_0x109827['attributes']=_[_0x0f0c('0x41')](_0x426c58['model'],qs[_0x0f0c('0x42')](_0x3e8b2d['query']['fields']));_0x109827[_0x0f0c('0x40')]=_0x109827['attributes']['length']?_0x109827[_0x0f0c('0x40')]:_0x426c58[_0x0f0c('0x3c')];if(_0x3e8b2d[_0x0f0c('0x3e')]['includeAll']){_0x109827[_0x0f0c('0x4c')]=[{'all':!![]}];}_0x109827=_['merge']({},_0x109827,_0x3e8b2d['options']);return db[_0x0f0c('0x37')][_0x0f0c('0x50')](_0x109827)[_0x0f0c('0x32')](handleEntityNotFound(_0xf60093,null))[_0x0f0c('0x32')](respondWithResult(_0xf60093,null))[_0x0f0c('0x26')](handleError(_0xf60093,null));};exports['create']=function(_0xbcc515,_0x50838d){return db[_0x0f0c('0x37')][_0x0f0c('0x51')](_0xbcc515['body'],{})[_0x0f0c('0x32')](respondWithResult(_0x50838d,0xc9))[_0x0f0c('0x26')](handleError(_0x50838d,null));};exports[_0x0f0c('0x52')]=function(_0x12d6b1,_0x5f5a72){if(_0x12d6b1['body']['id']){delete _0x12d6b1['body']['id'];}return db[_0x0f0c('0x37')][_0x0f0c('0x50')]({'where':{'id':_0x12d6b1[_0x0f0c('0x4f')]['id']}})['then'](handleEntityNotFound(_0x5f5a72,null))['then'](saveUpdates(_0x12d6b1['body'],null))[_0x0f0c('0x32')](respondWithResult(_0x5f5a72,null))[_0x0f0c('0x26')](handleError(_0x5f5a72,null));};exports[_0x0f0c('0x33')]=function(_0x26e8ab,_0x2ac021){return db[_0x0f0c('0x37')][_0x0f0c('0x50')]({'where':{'id':_0x26e8ab['params']['id']}})[_0x0f0c('0x32')](handleEntityNotFound(_0x2ac021,null))['then'](removeEntity(_0x2ac021,null))[_0x0f0c('0x26')](handleError(_0x2ac021,null));};exports['describe']=function(_0x5437a3,_0x133a93){return db[_0x0f0c('0x37')][_0x0f0c('0x53')]()['then'](respondWithResult(_0x133a93,null))[_0x0f0c('0x26')](handleError(_0x133a93,null));};var interaction_log=require(_0x0f0c('0x12'))(_0x0f0c('0x54'));exports[_0x0f0c('0x55')]=function(_0x226f43,_0x5007f1,_0x376497){var _0x528aa4={'agent':{},'channel':_0x0f0c('0x56')};if(_0x226f43['body']['id']){delete _0x226f43[_0x0f0c('0x57')]['id'];}_0x226f43['body'][_0x0f0c('0x58')]=!![];_0x226f43['body'][_0x0f0c('0x59')]=moment()[_0x0f0c('0x5a')]('YYYY-MM-DD\x20HH:mm:ss');_0x226f43[_0x0f0c('0x57')][_0x0f0c('0x5b')]=_0x226f43['body'][_0x0f0c('0x5b')]||_0x226f43['user']['id'];_0x528aa4[_0x0f0c('0x5c')]['id']=_0x226f43[_0x0f0c('0x57')][_0x0f0c('0x5b')];return db[_0x0f0c('0x37')]['find']({'where':{'id':_0x226f43[_0x0f0c('0x4f')]['id'],'UserId':null}})[_0x0f0c('0x32')](handleEntityNotFound(_0x5007f1,null))[_0x0f0c('0x32')](saveUpdates(_0x226f43[_0x0f0c('0x57')],null))[_0x0f0c('0x32')](function(_0x18edd5){if(_0x18edd5){_0x528aa4[_0x0f0c('0x24')]=_0x18edd5[_0x0f0c('0x5d')]({'plain':!![]});return db['WhatsappInteraction'][_0x0f0c('0x50')]({'where':{'id':_0x18edd5[_0x0f0c('0x5e')]}});}return null;})['then'](handleEntityNotFound(_0x5007f1,null))[_0x0f0c('0x32')](function(_0x51e93f){if(_0x51e93f){return _0x51e93f[_0x0f0c('0x52')]({'UserId':_0x226f43['body']['UserId'],'read1stAt':_['isNil'](_0x51e93f[_0x0f0c('0x5f')])?moment()[_0x0f0c('0x5a')](_0x0f0c('0x60')):undefined});}return null;})['then'](function(_0xf7f196){if(_0xf7f196){_0x528aa4[_0x0f0c('0x61')]=_0xf7f196[_0x0f0c('0x5d')]({'plain':!![]});interaction_log[_0x0f0c('0x62')](_0x0f0c('0x63'),_0x226f43['user']['id'],_0x226f43['user'][_0x0f0c('0x35')],_0x226f43[_0x0f0c('0x64')][_0x0f0c('0x65')],_0x528aa4['interaction']['id'],_0x226f43[_0x0f0c('0x57')]?JSON[_0x0f0c('0x21')](_0x226f43[_0x0f0c('0x57')]):_0x0f0c('0x66'));return respondWithRpcPromise('AcceptMessage',_0x0f0c('0x67'),_0x528aa4);}return null;})['then'](function(_0x278851){var _0x953337=_0x0f0c('0x68')+_0x278851[_0x0f0c('0x24')][_0x0f0c('0x69')];return db['sequelize'][_0x0f0c('0x3e')](_0x953337,{'type':db[_0x0f0c('0x6a')][_0x0f0c('0x6b')][_0x0f0c('0x6c')],'raw':!![]})[_0x0f0c('0x32')](function(_0x4c71df){return _0x4c71df;});})[_0x0f0c('0x32')](function(_0x52a86a){if(_0x52a86a){_0x528aa4[_0x0f0c('0x24')]['contact']=_0x52a86a[0x0];if(!_0x226f43[_0x0f0c('0x57')][_0x0f0c('0x5b')])return;return db[_0x0f0c('0x6d')][_0x0f0c('0x50')]({'where':{'id':_0x226f43[_0x0f0c('0x57')][_0x0f0c('0x5b')],'role':'agent'},'attributes':['id',_0x0f0c('0x35'),_0x0f0c('0x6e'),_0x0f0c('0x6f'),_0x0f0c('0x70')],'raw':!![]});}return null;})[_0x0f0c('0x32')](function(_0x34ac08){if(!_0x34ac08)return null;_0x528aa4['message'][_0x0f0c('0x5c')]=_0x34ac08;return _0x528aa4;})[_0x0f0c('0x32')](function(_0x409725){if(_0x409725){if(_0x226f43[_0x0f0c('0x57')][_0x0f0c('0x71')]){_0x528aa4[_0x0f0c('0x24')][_0x0f0c('0x72')]=util[_0x0f0c('0x5a')]('SIP/%s',_0x226f43['user']['name']);_0x528aa4['message'][_0x0f0c('0x73')]=_0x528aa4['channel'];_0x528aa4['message'][_0x0f0c('0x74')]=_0x528aa4['channel'];_0x528aa4[_0x0f0c('0x24')][_0x0f0c('0x75')]=_0x0f0c('0x55');return respondWithRpcPromise(_0x0f0c('0x76'),_0x0f0c('0x76'),{'event':'acceptmessage','message':_0x528aa4[_0x0f0c('0x24')]},client9002)[_0x0f0c('0x32')](function(){return _0x528aa4;});}return _0x528aa4;}return null;})[_0x0f0c('0x32')](respondWithResult(_0x5007f1,null))['catch'](handleError(_0x5007f1,null));};var interaction_log=require(_0x0f0c('0x12'))(_0x0f0c('0x54'));exports['reject']=function(_0x20a300,_0x3ba3d0,_0x568895){var _0x317797={'agent':{},'channel':_0x0f0c('0x56')};if(_0x20a300[_0x0f0c('0x57')]['id']){delete _0x20a300[_0x0f0c('0x57')]['id'];}_0x20a300[_0x0f0c('0x57')][_0x0f0c('0x5b')]=_0x20a300['body']['UserId']||_0x20a300['user']['id'];_0x317797['agent']['id']=_0x20a300[_0x0f0c('0x57')][_0x0f0c('0x5b')];return db[_0x0f0c('0x37')][_0x0f0c('0x50')]({'where':{'id':_0x20a300[_0x0f0c('0x4f')]['id'],'UserId':null}})[_0x0f0c('0x32')](handleEntityNotFound(_0x3ba3d0,null))[_0x0f0c('0x32')](function(_0x2808df){if(_0x2808df){_0x317797[_0x0f0c('0x24')]=_0x2808df[_0x0f0c('0x5d')]({'plain':!![]});return db['WhatsappInteraction'][_0x0f0c('0x50')]({'where':{'id':_0x2808df[_0x0f0c('0x5e')]}});}return null;})[_0x0f0c('0x32')](handleEntityNotFound(_0x3ba3d0,null))['then'](function(_0x5d92a8){if(_0x5d92a8){_0x317797['interaction']=_0x5d92a8[_0x0f0c('0x5d')]({'plain':!![]});interaction_log[_0x0f0c('0x62')](_0x0f0c('0x77'),_0x20a300[_0x0f0c('0x64')]['id'],_0x20a300[_0x0f0c('0x64')][_0x0f0c('0x35')],_0x20a300[_0x0f0c('0x64')][_0x0f0c('0x65')],_0x317797[_0x0f0c('0x61')]['id'],_0x20a300['body']?JSON['stringify'](_0x20a300[_0x0f0c('0x57')]):_0x0f0c('0x66'));return respondWithRpcPromise(_0x0f0c('0x78'),_0x0f0c('0x79'),_0x317797);}return null;})[_0x0f0c('0x32')](function(_0xbdee6b){var _0x4181b7=_0x0f0c('0x68')+_0xbdee6b[_0x0f0c('0x24')][_0x0f0c('0x69')];return db['sequelize'][_0x0f0c('0x3e')](_0x4181b7,{'type':db[_0x0f0c('0x6a')]['QueryTypes'][_0x0f0c('0x6c')],'raw':!![]})[_0x0f0c('0x32')](function(_0x21996e){return _0x21996e;});})[_0x0f0c('0x32')](function(_0x17cc13){if(_0x17cc13){_0x317797[_0x0f0c('0x24')][_0x0f0c('0x7a')]=_0x17cc13[0x0];if(!_0x20a300[_0x0f0c('0x57')][_0x0f0c('0x5b')])return;return db[_0x0f0c('0x6d')][_0x0f0c('0x50')]({'where':{'id':_0x20a300[_0x0f0c('0x57')]['UserId'],'role':_0x0f0c('0x5c')},'attributes':['id',_0x0f0c('0x35'),_0x0f0c('0x6e'),_0x0f0c('0x6f'),_0x0f0c('0x70')],'raw':!![]});}return null;})['then'](function(_0xc41579){if(!_0xc41579)return null;_0x317797[_0x0f0c('0x24')][_0x0f0c('0x5c')]=_0xc41579;return _0x317797;})['then'](function(_0x5ea802){if(_0x5ea802){_0x5ea802['message'][_0x0f0c('0x72')]=util[_0x0f0c('0x5a')](_0x0f0c('0x7b'),_0x20a300[_0x0f0c('0x64')][_0x0f0c('0x35')]);_0x5ea802[_0x0f0c('0x24')][_0x0f0c('0x73')]=_0x317797[_0x0f0c('0x73')];_0x5ea802[_0x0f0c('0x24')][_0x0f0c('0x74')]=_0x317797['channel'];_0x5ea802[_0x0f0c('0x24')]['event']=_0x0f0c('0x30');respondWithRpcPromise(_0x0f0c('0x76'),'EventManager',{'event':'rejectmessage','message':_0x5ea802[_0x0f0c('0x24')]},client9002);return _0x317797;}return null;})[_0x0f0c('0x32')](respondWithResult(_0x3ba3d0,null))['catch'](handleError(_0x3ba3d0,null));};exports[_0x0f0c('0x28')]=function(_0x34fc46,_0x38f526,_0x4e149a){if(_0x34fc46[_0x0f0c('0x57')]['id']){delete _0x34fc46['body']['id'];}var _0x253ba3;return db[_0x0f0c('0x37')]['find']({'where':{'id':_0x34fc46['params']['id']}})[_0x0f0c('0x32')](handleEntityNotFound(_0x38f526,null))[_0x0f0c('0x32')](function(_0x231dec){if(_0x231dec){_0x253ba3=_0x231dec;return db[_0x0f0c('0x7c')][_0x0f0c('0x50')]({'where':{'id':_0x231dec['WhatsappAccountId']}});}})['then'](handleEntityNotFound(_0x38f526,null))[_0x0f0c('0x32')](function(_0x46ca8f){if(_0x46ca8f){logger['debug'](_0x0f0c('0x7d'),_0x0f0c('0x28'),_0x0f0c('0x7e'),_0x46ca8f[_0x0f0c('0x3a')],util[_0x0f0c('0x7f')](_0x34fc46['body'],{'showHidden':![],'depth':null}));switch(_0x46ca8f[_0x0f0c('0x3a')]){case _0x0f0c('0x80'):if(_0x34fc46['body'][_0x0f0c('0x81')]&&_0x34fc46[_0x0f0c('0x57')][_0x0f0c('0x81')]===_0x253ba3[_0x0f0c('0x82')]&&_0x34fc46['body'][_0x0f0c('0x83')]&&_0x34fc46['body'][_0x0f0c('0x83')]===_0x0f0c('0x58')){return _0x253ba3[_0x0f0c('0x52')]({'read':!![]});}else{logger[_0x0f0c('0x22')](_0x0f0c('0x84'),_0x0f0c('0x28'),_0x0f0c('0x80'),util[_0x0f0c('0x7f')](_0x34fc46[_0x0f0c('0x57')],{'showHidden':![],'depth':null}));}break;}return _0x253ba3;}})[_0x0f0c('0x32')](respondWithResult(_0x38f526,null))['catch'](handleError(_0x38f526,null));};
\ No newline at end of file