Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / smsMessage / smsMessage.controller.js
index d730bcb..6ab578e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2d1f=['update','describe','sms-interactions','accept','sms','read','format','UserId','user','agent','CmContact','SmsInteraction','SmsInteractionId','isNil','read1stAt','YYYY-MM-DD\x20HH:mm:ss','interaction','get','stringify','null','acceptMessage','manual','SIP/%s','channel','event','EventManager','acceptmessage','role','RejectMessage','rejectMessage','interface','reject','rejectmessage','SmsAccount','SmsAccountId','debug','received\x20delivery\x20report\x20from','inspect','twilio','MessageSid','messageId','sent','delivered','Status','SmsAccount,\x20%s,\x20%s,\x20%s','plivio','results','groupName','DELIVERED','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./smsMessage.socket','register','jayson/promise','client','http','request','then','info','request\x20sent','SmsMessage,\x20%s,\x20%s,\x20%s','code','SmsMessage,\x20%s,\x20%s','error','message','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','save','destroy','name','send','index','map','SmsMessage','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','params','find','create','body'];(function(_0x3e186f,_0x2eb7be){var _0x3595bf=function(_0x5cb578){while(--_0x5cb578){_0x3e186f['push'](_0x3e186f['shift']());}};_0x3595bf(++_0x2eb7be);}(_0x2d1f,0x1d8));var _0xf2d1=function(_0x439dac,_0x3e40ce){_0x439dac=_0x439dac-0x0;var _0x114425=_0x2d1f[_0x439dac];return _0x114425;};'use strict';var emlformat=require(_0xf2d1('0x0'));var rimraf=require(_0xf2d1('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf2d1('0x2'));var rp=require(_0xf2d1('0x3'));var moment=require(_0xf2d1('0x4'));var BPromise=require(_0xf2d1('0x5'));var Mustache=require(_0xf2d1('0x6'));var util=require(_0xf2d1('0x7'));var path=require(_0xf2d1('0x8'));var sox=require(_0xf2d1('0x9'));var csv=require(_0xf2d1('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf2d1('0xb'));var _=require('lodash');var squel=require(_0xf2d1('0xc'));var crypto=require(_0xf2d1('0xd'));var jsforce=require(_0xf2d1('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xf2d1('0xa'));var querystring=require(_0xf2d1('0xf'));var Papa=require(_0xf2d1('0x10'));var Redis=require(_0xf2d1('0x11'));var authService=require(_0xf2d1('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xf2d1('0x13'));var hardwareService=require(_0xf2d1('0x14'));var logger=require(_0xf2d1('0x15'))(_0xf2d1('0x16'));var utils=require(_0xf2d1('0x17'));var config=require(_0xf2d1('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xf2d1('0x19'))['db'];config['redis']=_['defaults'](config[_0xf2d1('0x1a')],{'host':_0xf2d1('0x1b'),'port':0x18eb});var socket=require(_0xf2d1('0x1c'))(new Redis(config[_0xf2d1('0x1a')]));require(_0xf2d1('0x1d'))[_0xf2d1('0x1e')](socket);var jayson=require(_0xf2d1('0x1f'));var client=jayson[_0xf2d1('0x20')][_0xf2d1('0x21')]({'port':0x232c});var client9002=jayson[_0xf2d1('0x20')][_0xf2d1('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x5bfc1f,_0x5144a4,_0xc97920,_0x8146d){return new BPromise(function(_0x44523d,_0x4b64c6){var _0x221548=_0x8146d||client;return _0x221548[_0xf2d1('0x22')](_0x5bfc1f,_0xc97920)[_0xf2d1('0x23')](function(_0x5aba2e){logger[_0xf2d1('0x24')]('SmsMessage,\x20%s,\x20%s',_0x5144a4,_0xf2d1('0x25'));logger['debug'](_0xf2d1('0x26'),_0x5144a4,_0xf2d1('0x25'),JSON['stringify'](_0x5aba2e));if(_0x5aba2e['error']){if(_0x5aba2e['error'][_0xf2d1('0x27')]===0x1f4){logger['error'](_0xf2d1('0x28'),_0x5144a4,_0x5aba2e[_0xf2d1('0x29')][_0xf2d1('0x2a')]);return _0x4b64c6(_0x5aba2e['error'][_0xf2d1('0x2a')]);}logger['error'](_0xf2d1('0x28'),_0x5144a4,_0x5aba2e[_0xf2d1('0x29')]['message']);return _0x44523d(_0x5aba2e[_0xf2d1('0x29')][_0xf2d1('0x2a')]);}else{logger[_0xf2d1('0x24')](_0xf2d1('0x28'),_0x5144a4,_0xf2d1('0x25'));_0x44523d(_0x5aba2e['result']['message']);}})['catch'](function(_0x4698a8){logger[_0xf2d1('0x29')](_0xf2d1('0x28'),_0x5144a4,_0x4698a8);_0x4b64c6(_0x4698a8);});});}function respondWithStatusCode(_0x1b4cdd,_0x859bec){_0x859bec=_0x859bec||0xcc;return function(_0xc46021){if(_0xc46021){return _0x1b4cdd[_0xf2d1('0x2b')](_0x859bec);}return _0x1b4cdd[_0xf2d1('0x2c')](_0x859bec)[_0xf2d1('0x2d')]();};}function respondWithResult(_0x1fc55d,_0x12c43e){_0x12c43e=_0x12c43e||0xc8;return function(_0x308e3b){if(_0x308e3b){return _0x1fc55d[_0xf2d1('0x2c')](_0x12c43e)['json'](_0x308e3b);}};}function respondWithFilteredResult(_0x2db348,_0xa8e7ba){return function(_0x2ee792){if(_0x2ee792){var _0x508a50=typeof _0xa8e7ba[_0xf2d1('0x2e')]===_0xf2d1('0x2f')&&typeof _0xa8e7ba[_0xf2d1('0x30')]===_0xf2d1('0x2f');var _0x56c157=_0x2ee792[_0xf2d1('0x31')];var _0x373db6=_0x508a50?0x0:_0xa8e7ba[_0xf2d1('0x2e')];var _0x55dd92=_0x508a50?_0x2ee792[_0xf2d1('0x31')]:_0xa8e7ba[_0xf2d1('0x2e')]+_0xa8e7ba[_0xf2d1('0x30')];var _0x5abb99;if(_0x55dd92>=_0x56c157){_0x55dd92=_0x56c157;_0x5abb99=0xc8;}else{_0x5abb99=0xce;}_0x2db348[_0xf2d1('0x2c')](_0x5abb99);return _0x2db348[_0xf2d1('0x32')](_0xf2d1('0x33'),_0x373db6+'-'+_0x55dd92+'/'+_0x56c157)[_0xf2d1('0x34')](_0x2ee792);}return null;};}function patchUpdates(_0x2c1780){return function(_0x17b89e){try{jsonpatch[_0xf2d1('0x35')](_0x17b89e,_0x2c1780,!![]);}catch(_0x5f74a5){return BPromise['reject'](_0x5f74a5);}return _0x17b89e[_0xf2d1('0x36')]();};}function saveUpdates(_0x15ed4c,_0x549f62){return function(_0x57799a){if(_0x57799a){return _0x57799a['update'](_0x15ed4c)[_0xf2d1('0x23')](function(_0x301fd8){return _0x301fd8;});}return null;};}function removeEntity(_0x3c75fc,_0x23a9e0){return function(_0x3931f2){if(_0x3931f2){return _0x3931f2[_0xf2d1('0x37')]()[_0xf2d1('0x23')](function(){_0x3c75fc[_0xf2d1('0x2c')](0xcc)[_0xf2d1('0x2d')]();});}};}function handleEntityNotFound(_0x58afc6,_0x179fa0){return function(_0x556c86){if(!_0x556c86){_0x58afc6[_0xf2d1('0x2b')](0x194);}return _0x556c86;};}function handleError(_0x986177,_0x49f422){_0x49f422=_0x49f422||0x1f4;return function(_0x37d192){logger[_0xf2d1('0x29')](_0x37d192['stack']);if(_0x37d192[_0xf2d1('0x38')]){delete _0x37d192['name'];}_0x986177[_0xf2d1('0x2c')](_0x49f422)[_0xf2d1('0x39')](_0x37d192);};}exports[_0xf2d1('0x3a')]=function(_0x65a452,_0x1698f7){var _0x117950={},_0x47bfc3={},_0x24f0c6={'count':0x0,'rows':[]};var _0x151783=_[_0xf2d1('0x3b')](db[_0xf2d1('0x3c')][_0xf2d1('0x3d')],function(_0x4a686e){return{'name':_0x4a686e[_0xf2d1('0x3e')],'type':_0x4a686e[_0xf2d1('0x3f')][_0xf2d1('0x40')]};});_0x47bfc3['model']=_['map'](_0x151783,_0xf2d1('0x38'));_0x47bfc3[_0xf2d1('0x41')]=_[_0xf2d1('0x42')](_0x65a452[_0xf2d1('0x41')]);_0x47bfc3[_0xf2d1('0x43')]=_['intersection'](_0x47bfc3['model'],_0x47bfc3[_0xf2d1('0x41')]);_0x117950['attributes']=_[_0xf2d1('0x44')](_0x47bfc3[_0xf2d1('0x45')],qs[_0xf2d1('0x46')](_0x65a452[_0xf2d1('0x41')]['fields']));_0x117950[_0xf2d1('0x47')]=_0x117950[_0xf2d1('0x47')][_0xf2d1('0x48')]?_0x117950[_0xf2d1('0x47')]:_0x47bfc3[_0xf2d1('0x45')];if(!_0x65a452[_0xf2d1('0x41')][_0xf2d1('0x49')](_0xf2d1('0x4a'))){_0x117950['limit']=qs[_0xf2d1('0x30')](_0x65a452[_0xf2d1('0x41')][_0xf2d1('0x30')]);_0x117950[_0xf2d1('0x2e')]=qs[_0xf2d1('0x2e')](_0x65a452[_0xf2d1('0x41')]['offset']);}_0x117950[_0xf2d1('0x4b')]=qs[_0xf2d1('0x4c')](_0x65a452[_0xf2d1('0x41')]['sort']);_0x117950[_0xf2d1('0x4d')]=qs[_0xf2d1('0x43')](_[_0xf2d1('0x4e')](_0x65a452[_0xf2d1('0x41')],_0x47bfc3[_0xf2d1('0x43')]),_0x151783);if(_0x65a452['query'][_0xf2d1('0x4f')]){_0x117950['where']=_['merge'](_0x117950[_0xf2d1('0x4d')],{'$or':_[_0xf2d1('0x3b')](_0x151783,function(_0x57aee0){if(_0x57aee0['type']!==_0xf2d1('0x50')){var _0x150839={};_0x150839[_0x57aee0['name']]={'$like':'%'+_0x65a452[_0xf2d1('0x41')][_0xf2d1('0x4f')]+'%'};return _0x150839;}})});}_0x117950=_[_0xf2d1('0x51')]({},_0x117950,_0x65a452[_0xf2d1('0x52')]);var _0x4cc10f={'where':_0x117950['where']};return db[_0xf2d1('0x3c')][_0xf2d1('0x31')](_0x4cc10f)[_0xf2d1('0x23')](function(_0x36837e){_0x24f0c6[_0xf2d1('0x31')]=_0x36837e;if(_0x65a452[_0xf2d1('0x41')][_0xf2d1('0x53')]){_0x117950[_0xf2d1('0x54')]=[{'all':!![]}];}return db[_0xf2d1('0x3c')][_0xf2d1('0x55')](_0x117950);})['then'](function(_0x57ba45){_0x24f0c6[_0xf2d1('0x56')]=_0x57ba45;return _0x24f0c6;})[_0xf2d1('0x23')](respondWithFilteredResult(_0x1698f7,_0x117950))[_0xf2d1('0x57')](handleError(_0x1698f7,null));};exports['show']=function(_0x176d4d,_0x25cb18){var _0x2935f4={'raw':!![],'where':{'id':_0x176d4d[_0xf2d1('0x58')]['id']}},_0x42e10c={};_0x42e10c[_0xf2d1('0x45')]=_[_0xf2d1('0x42')](db[_0xf2d1('0x3c')]['rawAttributes']);_0x42e10c[_0xf2d1('0x41')]=_[_0xf2d1('0x42')](_0x176d4d[_0xf2d1('0x41')]);_0x42e10c[_0xf2d1('0x43')]=_[_0xf2d1('0x44')](_0x42e10c['model'],_0x42e10c['query']);_0x2935f4[_0xf2d1('0x47')]=_[_0xf2d1('0x44')](_0x42e10c['model'],qs[_0xf2d1('0x46')](_0x176d4d[_0xf2d1('0x41')][_0xf2d1('0x46')]));_0x2935f4['attributes']=_0x2935f4[_0xf2d1('0x47')][_0xf2d1('0x48')]?_0x2935f4[_0xf2d1('0x47')]:_0x42e10c[_0xf2d1('0x45')];if(_0x176d4d['query'][_0xf2d1('0x53')]){_0x2935f4[_0xf2d1('0x54')]=[{'all':!![]}];}_0x2935f4=_['merge']({},_0x2935f4,_0x176d4d[_0xf2d1('0x52')]);return db['SmsMessage'][_0xf2d1('0x59')](_0x2935f4)[_0xf2d1('0x23')](handleEntityNotFound(_0x25cb18,null))[_0xf2d1('0x23')](respondWithResult(_0x25cb18,null))[_0xf2d1('0x57')](handleError(_0x25cb18,null));};exports[_0xf2d1('0x5a')]=function(_0x32ceb3,_0x164366){return db[_0xf2d1('0x3c')]['create'](_0x32ceb3[_0xf2d1('0x5b')],{})['then'](respondWithResult(_0x164366,0xc9))[_0xf2d1('0x57')](handleError(_0x164366,null));};exports[_0xf2d1('0x5c')]=function(_0x4d4ade,_0x518801){if(_0x4d4ade[_0xf2d1('0x5b')]['id']){delete _0x4d4ade['body']['id'];}return db[_0xf2d1('0x3c')]['find']({'where':{'id':_0x4d4ade[_0xf2d1('0x58')]['id']}})[_0xf2d1('0x23')](handleEntityNotFound(_0x518801,null))[_0xf2d1('0x23')](saveUpdates(_0x4d4ade[_0xf2d1('0x5b')],null))['then'](respondWithResult(_0x518801,null))[_0xf2d1('0x57')](handleError(_0x518801,null));};exports[_0xf2d1('0x37')]=function(_0x3d24cc,_0x1b3a3f){return db[_0xf2d1('0x3c')][_0xf2d1('0x59')]({'where':{'id':_0x3d24cc[_0xf2d1('0x58')]['id']}})['then'](handleEntityNotFound(_0x1b3a3f,null))[_0xf2d1('0x23')](removeEntity(_0x1b3a3f,null))[_0xf2d1('0x57')](handleError(_0x1b3a3f,null));};exports[_0xf2d1('0x5d')]=function(_0x76227b,_0x1761cc){return db[_0xf2d1('0x3c')][_0xf2d1('0x5d')]()[_0xf2d1('0x23')](respondWithResult(_0x1761cc,null))['catch'](handleError(_0x1761cc,null));};var interaction_log=require(_0xf2d1('0x15'))(_0xf2d1('0x5e'));exports[_0xf2d1('0x5f')]=function(_0x3b5c01,_0x51d2b6,_0x223f90){var _0x4f4801={'agent':{},'channel':_0xf2d1('0x60')};if(_0x3b5c01[_0xf2d1('0x5b')]['id']){delete _0x3b5c01[_0xf2d1('0x5b')]['id'];}_0x3b5c01[_0xf2d1('0x5b')][_0xf2d1('0x61')]=!![];_0x3b5c01[_0xf2d1('0x5b')]['readAt']=moment()[_0xf2d1('0x62')]('YYYY-MM-DD\x20HH:mm:ss');_0x3b5c01['body'][_0xf2d1('0x63')]=_0x3b5c01[_0xf2d1('0x5b')][_0xf2d1('0x63')]||_0x3b5c01[_0xf2d1('0x64')]['id'];_0x4f4801[_0xf2d1('0x65')]['id']=_0x3b5c01[_0xf2d1('0x5b')][_0xf2d1('0x63')];return db['SmsMessage']['find']({'where':{'id':_0x3b5c01['params']['id'],'UserId':null},'include':[{'model':db[_0xf2d1('0x66')],'as':'Contact'}]})['then'](handleEntityNotFound(_0x51d2b6,null))[_0xf2d1('0x23')](saveUpdates(_0x3b5c01[_0xf2d1('0x5b')],null))['then'](function(_0x35ac7f){if(_0x35ac7f){_0x4f4801[_0xf2d1('0x2a')]=_0x35ac7f['get']({'plain':!![]});return db[_0xf2d1('0x67')][_0xf2d1('0x59')]({'where':{'id':_0x35ac7f[_0xf2d1('0x68')]}});}return null;})[_0xf2d1('0x23')](handleEntityNotFound(_0x51d2b6,null))[_0xf2d1('0x23')](function(_0x5487e9){if(_0x5487e9){return _0x5487e9[_0xf2d1('0x5c')]({'UserId':_0x3b5c01[_0xf2d1('0x5b')][_0xf2d1('0x63')],'read1stAt':_[_0xf2d1('0x69')](_0x5487e9[_0xf2d1('0x6a')])?moment()['format'](_0xf2d1('0x6b')):undefined});}return null;})[_0xf2d1('0x23')](function(_0x1378f6){if(_0x1378f6){_0x4f4801[_0xf2d1('0x6c')]=_0x1378f6[_0xf2d1('0x6d')]({'plain':!![]});interaction_log[_0xf2d1('0x24')]('[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x3b5c01[_0xf2d1('0x64')]['id'],_0x3b5c01[_0xf2d1('0x64')][_0xf2d1('0x38')],_0x3b5c01[_0xf2d1('0x64')]['role'],_0x4f4801[_0xf2d1('0x6c')]['id'],_0x3b5c01['body']?JSON[_0xf2d1('0x6e')](_0x3b5c01[_0xf2d1('0x5b')]):_0xf2d1('0x6f'));return respondWithRpcPromise('AcceptMessage',_0xf2d1('0x70'),_0x4f4801);}return null;})[_0xf2d1('0x23')](function(_0x761006){if(_0x761006){if(_0x3b5c01['body'][_0xf2d1('0x71')]){_0x4f4801['message']['interface']=util[_0xf2d1('0x62')](_0xf2d1('0x72'),_0x3b5c01[_0xf2d1('0x64')]['name']);_0x4f4801['message'][_0xf2d1('0x73')]=_0x4f4801[_0xf2d1('0x73')];_0x4f4801[_0xf2d1('0x2a')][_0xf2d1('0x74')]=_0xf2d1('0x5f');return respondWithRpcPromise(_0xf2d1('0x75'),'EventManager',{'event':_0xf2d1('0x76'),'message':_0x4f4801['message']},client9002)[_0xf2d1('0x23')](function(){return _0x4f4801;});}return _0x4f4801;}return null;})[_0xf2d1('0x23')](respondWithResult(_0x51d2b6,null))[_0xf2d1('0x57')](handleError(_0x51d2b6,null));};var interaction_log=require(_0xf2d1('0x15'))(_0xf2d1('0x5e'));exports['reject']=function(_0x3f865a,_0x1b3582,_0x41c64e){var _0x2f1703={'agent':{},'channel':_0xf2d1('0x60')};if(_0x3f865a[_0xf2d1('0x5b')]['id']){delete _0x3f865a[_0xf2d1('0x5b')]['id'];}_0x3f865a[_0xf2d1('0x5b')][_0xf2d1('0x63')]=_0x3f865a[_0xf2d1('0x5b')][_0xf2d1('0x63')]||_0x3f865a['user']['id'];_0x2f1703[_0xf2d1('0x65')]['id']=_0x3f865a[_0xf2d1('0x5b')][_0xf2d1('0x63')];return db['SmsMessage'][_0xf2d1('0x59')]({'where':{'id':_0x3f865a[_0xf2d1('0x58')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x1b3582,null))[_0xf2d1('0x23')](function(_0x362bc7){if(_0x362bc7){_0x2f1703[_0xf2d1('0x2a')]=_0x362bc7[_0xf2d1('0x6d')]({'plain':!![]});return db[_0xf2d1('0x67')]['find']({'where':{'id':_0x362bc7[_0xf2d1('0x68')]}});}return null;})[_0xf2d1('0x23')](handleEntityNotFound(_0x1b3582,null))[_0xf2d1('0x23')](function(_0x4e13a7){if(_0x4e13a7){_0x2f1703[_0xf2d1('0x6c')]=_0x4e13a7[_0xf2d1('0x6d')]({'plain':!![]});interaction_log[_0xf2d1('0x24')]('[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x3f865a[_0xf2d1('0x64')]['id'],_0x3f865a[_0xf2d1('0x64')][_0xf2d1('0x38')],_0x3f865a['user'][_0xf2d1('0x77')],_0x2f1703['interaction']['id'],_0x3f865a[_0xf2d1('0x5b')]?JSON[_0xf2d1('0x6e')](_0x3f865a['body']):_0xf2d1('0x6f'));return respondWithRpcPromise(_0xf2d1('0x78'),_0xf2d1('0x79'),_0x2f1703);}return null;})[_0xf2d1('0x23')](function(_0xd72636){if(_0xd72636){_0xd72636[_0xf2d1('0x2a')][_0xf2d1('0x7a')]=util[_0xf2d1('0x62')](_0xf2d1('0x72'),_0x3f865a[_0xf2d1('0x64')]['name']);_0xd72636['message'][_0xf2d1('0x73')]=_0x2f1703[_0xf2d1('0x73')];_0xd72636[_0xf2d1('0x2a')][_0xf2d1('0x74')]=_0xf2d1('0x7b');respondWithRpcPromise(_0xf2d1('0x75'),_0xf2d1('0x75'),{'event':_0xf2d1('0x7c'),'message':_0xd72636[_0xf2d1('0x2a')]},client9002);return _0x2f1703;}return null;})[_0xf2d1('0x23')](respondWithResult(_0x1b3582,null))[_0xf2d1('0x57')](handleError(_0x1b3582,null));};exports[_0xf2d1('0x2c')]=function(_0x451156,_0x2c64e6,_0x33359f){if(_0x451156[_0xf2d1('0x5b')]['id']){delete _0x451156[_0xf2d1('0x5b')]['id'];}var _0x29257e;return db['SmsMessage'][_0xf2d1('0x59')]({'where':{'id':_0x451156['params']['id']}})['then'](handleEntityNotFound(_0x2c64e6,null))[_0xf2d1('0x23')](function(_0x256dde){if(_0x256dde){_0x29257e=_0x256dde;return db[_0xf2d1('0x7d')][_0xf2d1('0x59')]({'where':{'id':_0x256dde[_0xf2d1('0x7e')]}});}})[_0xf2d1('0x23')](handleEntityNotFound(_0x2c64e6,null))['then'](function(_0x2f6733){if(_0x2f6733){logger[_0xf2d1('0x7f')](_0xf2d1('0x26'),_0xf2d1('0x2c'),_0xf2d1('0x80'),_0x2f6733[_0xf2d1('0x3f')],util[_0xf2d1('0x81')](_0x451156[_0xf2d1('0x5b')],{'showHidden':![],'depth':null}));switch(_0x2f6733[_0xf2d1('0x3f')]){case _0xf2d1('0x82'):if(_0x451156['body'][_0xf2d1('0x83')]&&_0x451156[_0xf2d1('0x5b')][_0xf2d1('0x83')]===_0x29257e[_0xf2d1('0x84')]){return _0x29257e[_0xf2d1('0x5c')]({'read':!![]});}else{logger[_0xf2d1('0x29')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0xf2d1('0x2c'),_0xf2d1('0x82'),util[_0xf2d1('0x81')](_0x451156['body'],{'showHidden':![],'depth':null}));}break;case'plivo':if(_0x451156[_0xf2d1('0x5b')]['MessageUUID']&&_0x451156['body']['MessageUUID']===_0x29257e[_0xf2d1('0x84')]&&_['indexOf']([_0xf2d1('0x85'),_0xf2d1('0x86')],_0x451156[_0xf2d1('0x5b')][_0xf2d1('0x87')])>=0x0){return _0x29257e['update']({'read':!![]});}else{logger['error'](_0xf2d1('0x88'),_0xf2d1('0x2c'),_0xf2d1('0x89'),util[_0xf2d1('0x81')](_0x451156['body'],{'showHidden':![],'depth':null}));}break;case'infobip':var _0xb252c1=_0x451156[_0xf2d1('0x5b')][_0xf2d1('0x8a')][0x0];if(_0xb252c1['status'][_0xf2d1('0x8b')]===_0xf2d1('0x8c')){return _0x29257e[_0xf2d1('0x5c')]({'read':!![]});}else{logger[_0xf2d1('0x29')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0xf2d1('0x2c'),'infobip',util[_0xf2d1('0x81')](_0x451156['body'],{'showHidden':![],'depth':null}));}break;}return _0x29257e;}})[_0xf2d1('0x23')](respondWithResult(_0x2c64e6,null))['catch'](handleError(_0x2c64e6,null));};
\ No newline at end of file
+var _0xea21=['ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./smsMessage.socket','jayson/promise','client','http','request','then','info','SmsMessage,\x20%s,\x20%s','request\x20sent','SmsMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','sendStatus','status','json','offset','undefined','limit','count','Content-Range','apply','reject','update','destroy','end','stack','name','send','map','SmsMessage','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','pick','filter','where','VIRTUAL','includeAll','include','show','params','find','create','body','describe','sms-interactions','sms','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','SmsInteraction','SmsInteractionId','isNil','read1stAt','interaction','role','null','AcceptMessage','acceptMessage','ContactId','sequelize','Sequelize','QueryTypes','SELECT','email','internal','interface','SIP/%s','channel','motionChannel','event','EventManager','acceptmessage','../../config/logger','get','[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','contact','rejectmessage','SmsAccount','SmsAccountId','received\x20delivery\x20report\x20from','inspect','MessageSid','messageId','SmsAccount,\x20%s,\x20%s,\x20%s','twilio','plivo','MessageUUID','indexOf','sent','Status','plivio','infobip','groupName','DELIVERED','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','papaparse'];(function(_0x5b9284,_0x1b3159){var _0x44266b=function(_0x3ee7e7){while(--_0x3ee7e7){_0x5b9284['push'](_0x5b9284['shift']());}};_0x44266b(++_0x1b3159);}(_0xea21,0x80));var _0x1ea2=function(_0x314405,_0x232782){_0x314405=_0x314405-0x0;var _0x4cf6cc=_0xea21[_0x314405];return _0x4cf6cc;};'use strict';var emlformat=require(_0x1ea2('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x1ea2('0x1'));var jsonpatch=require(_0x1ea2('0x2'));var rp=require(_0x1ea2('0x3'));var moment=require('moment');var BPromise=require(_0x1ea2('0x4'));var Mustache=require('mustache');var util=require(_0x1ea2('0x5'));var path=require(_0x1ea2('0x6'));var sox=require(_0x1ea2('0x7'));var csv=require(_0x1ea2('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x1ea2('0x9'));var _=require(_0x1ea2('0xa'));var squel=require(_0x1ea2('0xb'));var crypto=require(_0x1ea2('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x1ea2('0xd'));var toCsv=require(_0x1ea2('0x8'));var querystring=require('querystring');var Papa=require(_0x1ea2('0xe'));var Redis=require(_0x1ea2('0xf'));var authService=require(_0x1ea2('0x10'));var qs=require(_0x1ea2('0x11'));var as=require(_0x1ea2('0x12'));var hardwareService=require(_0x1ea2('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0x1ea2('0x14'));var config=require(_0x1ea2('0x15'));var licenseUtil=require(_0x1ea2('0x16'));var db=require(_0x1ea2('0x17'))['db'];config[_0x1ea2('0x18')]=_[_0x1ea2('0x19')](config[_0x1ea2('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0x1ea2('0x1a'))(new Redis(config[_0x1ea2('0x18')]));require(_0x1ea2('0x1b'))['register'](socket);var jayson=require(_0x1ea2('0x1c'));var client=jayson[_0x1ea2('0x1d')][_0x1ea2('0x1e')]({'port':0x232c});var client9002=jayson[_0x1ea2('0x1d')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3f2565,_0x372dc5,_0x27bb84,_0x14b984){return new BPromise(function(_0x28040b,_0x53965f){var _0x1d006b=_0x14b984||client;return _0x1d006b[_0x1ea2('0x1f')](_0x3f2565,_0x27bb84)[_0x1ea2('0x20')](function(_0x48a16e){logger[_0x1ea2('0x21')](_0x1ea2('0x22'),_0x372dc5,_0x1ea2('0x23'));logger['debug'](_0x1ea2('0x24'),_0x372dc5,_0x1ea2('0x23'),JSON[_0x1ea2('0x25')](_0x48a16e));if(_0x48a16e[_0x1ea2('0x26')]){if(_0x48a16e[_0x1ea2('0x26')]['code']===0x1f4){logger[_0x1ea2('0x26')](_0x1ea2('0x22'),_0x372dc5,_0x48a16e[_0x1ea2('0x26')][_0x1ea2('0x27')]);return _0x53965f(_0x48a16e[_0x1ea2('0x26')][_0x1ea2('0x27')]);}logger[_0x1ea2('0x26')](_0x1ea2('0x22'),_0x372dc5,_0x48a16e[_0x1ea2('0x26')]['message']);return _0x28040b(_0x48a16e[_0x1ea2('0x26')][_0x1ea2('0x27')]);}else{logger[_0x1ea2('0x21')](_0x1ea2('0x22'),_0x372dc5,'request\x20sent');_0x28040b(_0x48a16e['result'][_0x1ea2('0x27')]);}})[_0x1ea2('0x28')](function(_0x5a539b){logger[_0x1ea2('0x26')](_0x1ea2('0x22'),_0x372dc5,_0x5a539b);_0x53965f(_0x5a539b);});});}function respondWithStatusCode(_0x2dee14,_0x232d0e){_0x232d0e=_0x232d0e||0xcc;return function(_0x31b7a7){if(_0x31b7a7){return _0x2dee14[_0x1ea2('0x29')](_0x232d0e);}return _0x2dee14['status'](_0x232d0e)['end']();};}function respondWithResult(_0x366a83,_0x22ad41){_0x22ad41=_0x22ad41||0xc8;return function(_0x1a2699){if(_0x1a2699){return _0x366a83[_0x1ea2('0x2a')](_0x22ad41)[_0x1ea2('0x2b')](_0x1a2699);}};}function respondWithFilteredResult(_0x288b26,_0x53e48c){return function(_0x127d65){if(_0x127d65){var _0x492466=typeof _0x53e48c[_0x1ea2('0x2c')]===_0x1ea2('0x2d')&&typeof _0x53e48c[_0x1ea2('0x2e')]===_0x1ea2('0x2d');var _0x149251=_0x127d65[_0x1ea2('0x2f')];var _0x10dcf8=_0x492466?0x0:_0x53e48c[_0x1ea2('0x2c')];var _0x545ea5=_0x492466?_0x127d65['count']:_0x53e48c['offset']+_0x53e48c[_0x1ea2('0x2e')];var _0x53ee7f;if(_0x545ea5>=_0x149251){_0x545ea5=_0x149251;_0x53ee7f=0xc8;}else{_0x53ee7f=0xce;}_0x288b26[_0x1ea2('0x2a')](_0x53ee7f);return _0x288b26['set'](_0x1ea2('0x30'),_0x10dcf8+'-'+_0x545ea5+'/'+_0x149251)[_0x1ea2('0x2b')](_0x127d65);}return null;};}function patchUpdates(_0x24a1b4){return function(_0x2c081d){try{jsonpatch[_0x1ea2('0x31')](_0x2c081d,_0x24a1b4,!![]);}catch(_0x152e2b){return BPromise[_0x1ea2('0x32')](_0x152e2b);}return _0x2c081d['save']();};}function saveUpdates(_0xdbc11e,_0x39a07c){return function(_0x4eeb77){if(_0x4eeb77){return _0x4eeb77[_0x1ea2('0x33')](_0xdbc11e)[_0x1ea2('0x20')](function(_0x108b74){return _0x108b74;});}return null;};}function removeEntity(_0x3266a7,_0x3716ac){return function(_0x4b78bb){if(_0x4b78bb){return _0x4b78bb[_0x1ea2('0x34')]()['then'](function(){_0x3266a7[_0x1ea2('0x2a')](0xcc)[_0x1ea2('0x35')]();});}};}function handleEntityNotFound(_0x9a56ad,_0x38a0e9){return function(_0x2b825a){if(!_0x2b825a){_0x9a56ad[_0x1ea2('0x29')](0x194);}return _0x2b825a;};}function handleError(_0x134277,_0x6543f8){_0x6543f8=_0x6543f8||0x1f4;return function(_0x9e5ece){logger[_0x1ea2('0x26')](_0x9e5ece[_0x1ea2('0x36')]);if(_0x9e5ece[_0x1ea2('0x37')]){delete _0x9e5ece[_0x1ea2('0x37')];}_0x134277[_0x1ea2('0x2a')](_0x6543f8)[_0x1ea2('0x38')](_0x9e5ece);};}exports['index']=function(_0x4a4a4d,_0x411766){var _0x7acab0={},_0x3d241c={},_0x3c6ea5={'count':0x0,'rows':[]};var _0x4c189f=_[_0x1ea2('0x39')](db[_0x1ea2('0x3a')][_0x1ea2('0x3b')],function(_0x4cf0c8){return{'name':_0x4cf0c8[_0x1ea2('0x3c')],'type':_0x4cf0c8[_0x1ea2('0x3d')][_0x1ea2('0x3e')]};});_0x3d241c[_0x1ea2('0x3f')]=_['map'](_0x4c189f,'name');_0x3d241c['query']=_[_0x1ea2('0x40')](_0x4a4a4d[_0x1ea2('0x41')]);_0x3d241c[_0x1ea2('0x42')]=_[_0x1ea2('0x43')](_0x3d241c[_0x1ea2('0x3f')],_0x3d241c[_0x1ea2('0x41')]);_0x7acab0[_0x1ea2('0x44')]=_[_0x1ea2('0x43')](_0x3d241c[_0x1ea2('0x3f')],qs[_0x1ea2('0x45')](_0x4a4a4d['query'][_0x1ea2('0x45')]));_0x7acab0['attributes']=_0x7acab0[_0x1ea2('0x44')][_0x1ea2('0x46')]?_0x7acab0[_0x1ea2('0x44')]:_0x3d241c[_0x1ea2('0x3f')];if(!_0x4a4a4d[_0x1ea2('0x41')][_0x1ea2('0x47')]('nolimit')){_0x7acab0[_0x1ea2('0x2e')]=qs['limit'](_0x4a4a4d[_0x1ea2('0x41')][_0x1ea2('0x2e')]);_0x7acab0[_0x1ea2('0x2c')]=qs['offset'](_0x4a4a4d['query'][_0x1ea2('0x2c')]);}_0x7acab0[_0x1ea2('0x48')]=qs[_0x1ea2('0x49')](_0x4a4a4d[_0x1ea2('0x41')]['sort']);_0x7acab0['where']=qs['filters'](_[_0x1ea2('0x4a')](_0x4a4a4d['query'],_0x3d241c[_0x1ea2('0x42')]),_0x4c189f);if(_0x4a4a4d[_0x1ea2('0x41')][_0x1ea2('0x4b')]){_0x7acab0['where']=_['merge'](_0x7acab0[_0x1ea2('0x4c')],{'$or':_['map'](_0x4c189f,function(_0x56fd1b){if(_0x56fd1b[_0x1ea2('0x3d')]!==_0x1ea2('0x4d')){var _0x3dd0da={};_0x3dd0da[_0x56fd1b[_0x1ea2('0x37')]]={'$like':'%'+_0x4a4a4d[_0x1ea2('0x41')][_0x1ea2('0x4b')]+'%'};return _0x3dd0da;}})});}_0x7acab0=_['merge']({},_0x7acab0,_0x4a4a4d['options']);var _0x4e1a0e={'where':_0x7acab0['where']};return db['SmsMessage'][_0x1ea2('0x2f')](_0x4e1a0e)['then'](function(_0x2090da){_0x3c6ea5[_0x1ea2('0x2f')]=_0x2090da;if(_0x4a4a4d[_0x1ea2('0x41')][_0x1ea2('0x4e')]){_0x7acab0[_0x1ea2('0x4f')]=[{'all':!![]}];}return db[_0x1ea2('0x3a')]['findAll'](_0x7acab0);})[_0x1ea2('0x20')](function(_0xf025e5){_0x3c6ea5['rows']=_0xf025e5;return _0x3c6ea5;})[_0x1ea2('0x20')](respondWithFilteredResult(_0x411766,_0x7acab0))[_0x1ea2('0x28')](handleError(_0x411766,null));};exports[_0x1ea2('0x50')]=function(_0x17f675,_0x208cb6){var _0x5afd52={'raw':!![],'where':{'id':_0x17f675[_0x1ea2('0x51')]['id']}},_0x57e0f0={};_0x57e0f0[_0x1ea2('0x3f')]=_[_0x1ea2('0x40')](db[_0x1ea2('0x3a')]['rawAttributes']);_0x57e0f0['query']=_['keys'](_0x17f675[_0x1ea2('0x41')]);_0x57e0f0['filters']=_[_0x1ea2('0x43')](_0x57e0f0['model'],_0x57e0f0['query']);_0x5afd52[_0x1ea2('0x44')]=_['intersection'](_0x57e0f0[_0x1ea2('0x3f')],qs['fields'](_0x17f675[_0x1ea2('0x41')][_0x1ea2('0x45')]));_0x5afd52['attributes']=_0x5afd52['attributes'][_0x1ea2('0x46')]?_0x5afd52[_0x1ea2('0x44')]:_0x57e0f0[_0x1ea2('0x3f')];if(_0x17f675[_0x1ea2('0x41')][_0x1ea2('0x4e')]){_0x5afd52[_0x1ea2('0x4f')]=[{'all':!![]}];}_0x5afd52=_['merge']({},_0x5afd52,_0x17f675['options']);return db[_0x1ea2('0x3a')][_0x1ea2('0x52')](_0x5afd52)['then'](handleEntityNotFound(_0x208cb6,null))[_0x1ea2('0x20')](respondWithResult(_0x208cb6,null))[_0x1ea2('0x28')](handleError(_0x208cb6,null));};exports[_0x1ea2('0x53')]=function(_0x39daca,_0xf300e4){return db['SmsMessage'][_0x1ea2('0x53')](_0x39daca['body'],{})[_0x1ea2('0x20')](respondWithResult(_0xf300e4,0xc9))[_0x1ea2('0x28')](handleError(_0xf300e4,null));};exports[_0x1ea2('0x33')]=function(_0x246b44,_0x4dded6){if(_0x246b44[_0x1ea2('0x54')]['id']){delete _0x246b44['body']['id'];}return db['SmsMessage']['find']({'where':{'id':_0x246b44['params']['id']}})[_0x1ea2('0x20')](handleEntityNotFound(_0x4dded6,null))[_0x1ea2('0x20')](saveUpdates(_0x246b44[_0x1ea2('0x54')],null))['then'](respondWithResult(_0x4dded6,null))[_0x1ea2('0x28')](handleError(_0x4dded6,null));};exports[_0x1ea2('0x34')]=function(_0x1cd123,_0x7f7636){return db['SmsMessage'][_0x1ea2('0x52')]({'where':{'id':_0x1cd123['params']['id']}})[_0x1ea2('0x20')](handleEntityNotFound(_0x7f7636,null))['then'](removeEntity(_0x7f7636,null))[_0x1ea2('0x28')](handleError(_0x7f7636,null));};exports[_0x1ea2('0x55')]=function(_0x3e55cf,_0xee03ef){return db[_0x1ea2('0x3a')][_0x1ea2('0x55')]()[_0x1ea2('0x20')](respondWithResult(_0xee03ef,null))[_0x1ea2('0x28')](handleError(_0xee03ef,null));};var interaction_log=require('../../config/logger')(_0x1ea2('0x56'));exports['accept']=function(_0x1c3a82,_0x364a63,_0x59ae8d){var _0x20ce44={'agent':{},'channel':_0x1ea2('0x57')};if(_0x1c3a82[_0x1ea2('0x54')]['id']){delete _0x1c3a82['body']['id'];}_0x1c3a82[_0x1ea2('0x54')][_0x1ea2('0x58')]=!![];_0x1c3a82[_0x1ea2('0x54')][_0x1ea2('0x59')]=moment()[_0x1ea2('0x5a')](_0x1ea2('0x5b'));_0x1c3a82[_0x1ea2('0x54')][_0x1ea2('0x5c')]=_0x1c3a82[_0x1ea2('0x54')][_0x1ea2('0x5c')]||_0x1c3a82[_0x1ea2('0x5d')]['id'];_0x20ce44[_0x1ea2('0x5e')]['id']=_0x1c3a82[_0x1ea2('0x54')][_0x1ea2('0x5c')];return db[_0x1ea2('0x3a')]['find']({'where':{'id':_0x1c3a82[_0x1ea2('0x51')]['id'],'UserId':null}})[_0x1ea2('0x20')](handleEntityNotFound(_0x364a63,null))[_0x1ea2('0x20')](saveUpdates(_0x1c3a82[_0x1ea2('0x54')],null))[_0x1ea2('0x20')](function(_0x157ee8){if(_0x157ee8){_0x20ce44[_0x1ea2('0x27')]=_0x157ee8['get']({'plain':!![]});return db[_0x1ea2('0x5f')][_0x1ea2('0x52')]({'where':{'id':_0x157ee8[_0x1ea2('0x60')]}});}return null;})[_0x1ea2('0x20')](handleEntityNotFound(_0x364a63,null))[_0x1ea2('0x20')](function(_0x4fd0f4){if(_0x4fd0f4){return _0x4fd0f4[_0x1ea2('0x33')]({'UserId':_0x1c3a82[_0x1ea2('0x54')][_0x1ea2('0x5c')],'read1stAt':_[_0x1ea2('0x61')](_0x4fd0f4[_0x1ea2('0x62')])?moment()[_0x1ea2('0x5a')](_0x1ea2('0x5b')):undefined});}return null;})[_0x1ea2('0x20')](function(_0xcedbec){if(_0xcedbec){_0x20ce44[_0x1ea2('0x63')]=_0xcedbec['get']({'plain':!![]});interaction_log[_0x1ea2('0x21')]('[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x1c3a82[_0x1ea2('0x5d')]['id'],_0x1c3a82[_0x1ea2('0x5d')][_0x1ea2('0x37')],_0x1c3a82['user'][_0x1ea2('0x64')],_0x20ce44[_0x1ea2('0x63')]['id'],_0x1c3a82[_0x1ea2('0x54')]?JSON[_0x1ea2('0x25')](_0x1c3a82['body']):_0x1ea2('0x65'));return respondWithRpcPromise(_0x1ea2('0x66'),_0x1ea2('0x67'),_0x20ce44);}return null;})[_0x1ea2('0x20')](function(_0x2488a1){var _0x4ba554='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x2488a1['message'][_0x1ea2('0x68')];return db[_0x1ea2('0x69')]['query'](_0x4ba554,{'type':db[_0x1ea2('0x6a')][_0x1ea2('0x6b')][_0x1ea2('0x6c')],'raw':!![]})[_0x1ea2('0x20')](function(_0x2e50b5){return _0x2e50b5;});})[_0x1ea2('0x20')](function(_0x1eb347){if(_0x1eb347){_0x20ce44['message']['contact']=_0x1eb347[0x0];if(!_0x1c3a82[_0x1ea2('0x54')][_0x1ea2('0x5c')])return;return db['User'][_0x1ea2('0x52')]({'where':{'id':_0x1c3a82[_0x1ea2('0x54')]['UserId'],'role':_0x1ea2('0x5e')},'attributes':['id',_0x1ea2('0x37'),'fullname',_0x1ea2('0x6d'),_0x1ea2('0x6e')],'raw':!![]});}return null;})[_0x1ea2('0x20')](function(_0x547a65){if(!_0x547a65)return null;_0x20ce44['message'][_0x1ea2('0x5e')]=_0x547a65;return _0x20ce44;})['then'](function(_0x415555){if(_0x415555){if(_0x1c3a82['body']['manual']){_0x20ce44['message'][_0x1ea2('0x6f')]=util['format'](_0x1ea2('0x70'),_0x1c3a82[_0x1ea2('0x5d')][_0x1ea2('0x37')]);_0x20ce44[_0x1ea2('0x27')][_0x1ea2('0x71')]=_0x20ce44[_0x1ea2('0x71')];_0x20ce44['message'][_0x1ea2('0x72')]=_0x20ce44[_0x1ea2('0x71')];_0x20ce44[_0x1ea2('0x27')][_0x1ea2('0x73')]='accept';return respondWithRpcPromise(_0x1ea2('0x74'),_0x1ea2('0x74'),{'event':_0x1ea2('0x75'),'message':_0x20ce44[_0x1ea2('0x27')]},client9002)[_0x1ea2('0x20')](function(){return _0x20ce44;});}return _0x20ce44;}return null;})[_0x1ea2('0x20')](respondWithResult(_0x364a63,null))['catch'](handleError(_0x364a63,null));};var interaction_log=require(_0x1ea2('0x76'))(_0x1ea2('0x56'));exports[_0x1ea2('0x32')]=function(_0xe795a6,_0x4d996b,_0x19aa4c){var _0x4323cf={'agent':{},'channel':_0x1ea2('0x57')};if(_0xe795a6[_0x1ea2('0x54')]['id']){delete _0xe795a6[_0x1ea2('0x54')]['id'];}_0xe795a6[_0x1ea2('0x54')][_0x1ea2('0x5c')]=_0xe795a6[_0x1ea2('0x54')][_0x1ea2('0x5c')]||_0xe795a6['user']['id'];_0x4323cf['agent']['id']=_0xe795a6[_0x1ea2('0x54')][_0x1ea2('0x5c')];return db[_0x1ea2('0x3a')][_0x1ea2('0x52')]({'where':{'id':_0xe795a6['params']['id'],'UserId':null}})[_0x1ea2('0x20')](handleEntityNotFound(_0x4d996b,null))[_0x1ea2('0x20')](function(_0x10dc58){if(_0x10dc58){_0x4323cf[_0x1ea2('0x27')]=_0x10dc58['get']({'plain':!![]});return db[_0x1ea2('0x5f')]['find']({'where':{'id':_0x10dc58[_0x1ea2('0x60')]}});}return null;})[_0x1ea2('0x20')](handleEntityNotFound(_0x4d996b,null))['then'](function(_0x5f43ab){if(_0x5f43ab){_0x4323cf[_0x1ea2('0x63')]=_0x5f43ab[_0x1ea2('0x77')]({'plain':!![]});interaction_log[_0x1ea2('0x21')](_0x1ea2('0x78'),_0xe795a6['user']['id'],_0xe795a6['user']['name'],_0xe795a6['user']['role'],_0x4323cf[_0x1ea2('0x63')]['id'],_0xe795a6['body']?JSON['stringify'](_0xe795a6[_0x1ea2('0x54')]):_0x1ea2('0x65'));return respondWithRpcPromise(_0x1ea2('0x79'),_0x1ea2('0x7a'),_0x4323cf);}return null;})[_0x1ea2('0x20')](function(_0x504610){var _0x5c4362=_0x1ea2('0x7b')+_0x504610[_0x1ea2('0x27')]['ContactId'];return db[_0x1ea2('0x69')][_0x1ea2('0x41')](_0x5c4362,{'type':db[_0x1ea2('0x6a')][_0x1ea2('0x6b')][_0x1ea2('0x6c')],'raw':!![]})[_0x1ea2('0x20')](function(_0x377d2b){return _0x377d2b;});})[_0x1ea2('0x20')](function(_0x2a03e5){if(_0x2a03e5){_0x4323cf[_0x1ea2('0x27')][_0x1ea2('0x7c')]=_0x2a03e5[0x0];if(!_0xe795a6['body']['UserId'])return;return db['User']['find']({'where':{'id':_0xe795a6[_0x1ea2('0x54')][_0x1ea2('0x5c')],'role':_0x1ea2('0x5e')},'attributes':['id',_0x1ea2('0x37'),'fullname',_0x1ea2('0x6d'),_0x1ea2('0x6e')],'raw':!![]});}return null;})[_0x1ea2('0x20')](function(_0x3d5982){if(!_0x3d5982)return null;_0x4323cf[_0x1ea2('0x27')][_0x1ea2('0x5e')]=_0x3d5982;return _0x4323cf;})['then'](function(_0x5a7d77){if(_0x5a7d77){_0x5a7d77['message'][_0x1ea2('0x6f')]=util['format'](_0x1ea2('0x70'),_0xe795a6[_0x1ea2('0x5d')][_0x1ea2('0x37')]);_0x5a7d77[_0x1ea2('0x27')]['channel']=_0x4323cf[_0x1ea2('0x71')];_0x5a7d77[_0x1ea2('0x27')][_0x1ea2('0x72')]=_0x4323cf[_0x1ea2('0x71')];_0x5a7d77[_0x1ea2('0x27')][_0x1ea2('0x73')]=_0x1ea2('0x32');respondWithRpcPromise(_0x1ea2('0x74'),_0x1ea2('0x74'),{'event':_0x1ea2('0x7d'),'message':_0x5a7d77[_0x1ea2('0x27')]},client9002);return _0x4323cf;}return null;})[_0x1ea2('0x20')](respondWithResult(_0x4d996b,null))[_0x1ea2('0x28')](handleError(_0x4d996b,null));};exports[_0x1ea2('0x2a')]=function(_0x225f86,_0x53fdb8,_0x40a341){if(_0x225f86['body']['id']){delete _0x225f86['body']['id'];}var _0xdd392f;return db[_0x1ea2('0x3a')][_0x1ea2('0x52')]({'where':{'id':_0x225f86['params']['id']}})[_0x1ea2('0x20')](handleEntityNotFound(_0x53fdb8,null))['then'](function(_0x2c4c63){if(_0x2c4c63){_0xdd392f=_0x2c4c63;return db[_0x1ea2('0x7e')][_0x1ea2('0x52')]({'where':{'id':_0x2c4c63[_0x1ea2('0x7f')]}});}})[_0x1ea2('0x20')](handleEntityNotFound(_0x53fdb8,null))['then'](function(_0x27a77a){if(_0x27a77a){logger['debug'](_0x1ea2('0x24'),'status',_0x1ea2('0x80'),_0x27a77a[_0x1ea2('0x3d')],util[_0x1ea2('0x81')](_0x225f86['body'],{'showHidden':![],'depth':null}));switch(_0x27a77a[_0x1ea2('0x3d')]){case'twilio':if(_0x225f86[_0x1ea2('0x54')][_0x1ea2('0x82')]&&_0x225f86[_0x1ea2('0x54')][_0x1ea2('0x82')]===_0xdd392f[_0x1ea2('0x83')]){return _0xdd392f[_0x1ea2('0x33')]({'read':!![]});}else{logger['error'](_0x1ea2('0x84'),_0x1ea2('0x2a'),_0x1ea2('0x85'),util['inspect'](_0x225f86['body'],{'showHidden':![],'depth':null}));}break;case _0x1ea2('0x86'):if(_0x225f86['body'][_0x1ea2('0x87')]&&_0x225f86[_0x1ea2('0x54')][_0x1ea2('0x87')]===_0xdd392f['messageId']&&_[_0x1ea2('0x88')]([_0x1ea2('0x89'),'delivered'],_0x225f86[_0x1ea2('0x54')][_0x1ea2('0x8a')])>=0x0){return _0xdd392f[_0x1ea2('0x33')]({'read':!![]});}else{logger[_0x1ea2('0x26')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0x1ea2('0x2a'),_0x1ea2('0x8b'),util[_0x1ea2('0x81')](_0x225f86[_0x1ea2('0x54')],{'showHidden':![],'depth':null}));}break;case _0x1ea2('0x8c'):var _0x1f5cb3=_0x225f86[_0x1ea2('0x54')]['results'][0x0];if(_0x1f5cb3[_0x1ea2('0x2a')][_0x1ea2('0x8d')]===_0x1ea2('0x8e')){return _0xdd392f[_0x1ea2('0x33')]({'read':!![]});}else{logger[_0x1ea2('0x26')](_0x1ea2('0x84'),_0x1ea2('0x2a'),_0x1ea2('0x8c'),util[_0x1ea2('0x81')](_0x225f86[_0x1ea2('0x54')],{'showHidden':![],'depth':null}));}break;}return _0xdd392f;}})['then'](respondWithResult(_0x53fdb8,null))[_0x1ea2('0x28')](handleError(_0x53fdb8,null));};
\ No newline at end of file