Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / smsMessage / smsMessage.controller.js
index d730bcb..54122e5 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 _0x5dea=['pick','filter','where','merge','options','includeAll','findAll','include','find','create','body','params','destroy','describe','sms-interactions','accept','sms','read','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','CmContact','Contact','get','SmsInteraction','isNil','read1stAt','role','interaction','null','AcceptMessage','acceptMessage','manual','interface','SIP/%s','channel','event','acceptmessage','info','RejectMessage','EventManager','SmsAccount','SmsAccountId','SmsMessage,\x20%s,\x20%s,\x20%s','received\x20delivery\x20report\x20from','inspect','twilio','MessageSid','messageId','update','SmsAccount,\x20%s,\x20%s,\x20%s','plivo','MessageUUID','indexOf','delivered','results','groupName','infobip','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','to-csv','fs-extra','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','redis','defaults','localhost','jayson/promise','http','client','request','SmsMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','catch','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','then','name','send','index','SmsMessage','rawAttributes','fieldName','type','model','map','keys','query','filters','intersection','attributes','fields','length','nolimit','sort'];(function(_0x1e60dc,_0x1715be){var _0x41fa71=function(_0x528da9){while(--_0x528da9){_0x1e60dc['push'](_0x1e60dc['shift']());}};_0x41fa71(++_0x1715be);}(_0x5dea,0x1bc));var _0xa5de=function(_0x9fbf11,_0x19cc7a){_0x9fbf11=_0x9fbf11-0x0;var _0x33c563=_0x5dea[_0x9fbf11];return _0x33c563;};'use strict';var emlformat=require(_0xa5de('0x0'));var rimraf=require(_0xa5de('0x1'));var zipdir=require(_0xa5de('0x2'));var jsonpatch=require(_0xa5de('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xa5de('0x4'));var Mustache=require('mustache');var util=require(_0xa5de('0x5'));var path=require(_0xa5de('0x6'));var sox=require(_0xa5de('0x7'));var csv=require(_0xa5de('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa5de('0x9'));var _=require('lodash');var squel=require(_0xa5de('0xa'));var crypto=require(_0xa5de('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xa5de('0xc'));var toCsv=require(_0xa5de('0x8'));var querystring=require(_0xa5de('0xd'));var Papa=require(_0xa5de('0xe'));var Redis=require(_0xa5de('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xa5de('0x10'));var as=require(_0xa5de('0x11'));var hardwareService=require(_0xa5de('0x12'));var logger=require(_0xa5de('0x13'))(_0xa5de('0x14'));var utils=require('../../config/utils');var config=require(_0xa5de('0x15'));var licenseUtil=require(_0xa5de('0x16'));var db=require('../../mysqldb')['db'];config[_0xa5de('0x17')]=_[_0xa5de('0x18')](config[_0xa5de('0x17')],{'host':_0xa5de('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./smsMessage.socket')['register'](socket);var jayson=require(_0xa5de('0x1a'));var client=jayson['client'][_0xa5de('0x1b')]({'port':0x232c});var client9002=jayson[_0xa5de('0x1c')][_0xa5de('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x26aaa1,_0x5862dd,_0x2e8791,_0x17f304){return new BPromise(function(_0x1d4c54,_0x1e53a0){var _0x522d8e=_0x17f304||client;return _0x522d8e[_0xa5de('0x1d')](_0x26aaa1,_0x2e8791)['then'](function(_0x4eccb9){logger['info'](_0xa5de('0x1e'),_0x5862dd,_0xa5de('0x1f'));logger[_0xa5de('0x20')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x5862dd,_0xa5de('0x1f'),JSON[_0xa5de('0x21')](_0x4eccb9));if(_0x4eccb9[_0xa5de('0x22')]){if(_0x4eccb9[_0xa5de('0x22')]['code']===0x1f4){logger[_0xa5de('0x22')]('SmsMessage,\x20%s,\x20%s',_0x5862dd,_0x4eccb9[_0xa5de('0x22')]['message']);return _0x1e53a0(_0x4eccb9[_0xa5de('0x22')][_0xa5de('0x23')]);}logger[_0xa5de('0x22')](_0xa5de('0x1e'),_0x5862dd,_0x4eccb9[_0xa5de('0x22')][_0xa5de('0x23')]);return _0x1d4c54(_0x4eccb9[_0xa5de('0x22')][_0xa5de('0x23')]);}else{logger['info']('SmsMessage,\x20%s,\x20%s',_0x5862dd,_0xa5de('0x1f'));_0x1d4c54(_0x4eccb9['result'][_0xa5de('0x23')]);}})[_0xa5de('0x24')](function(_0x4bf21f){logger['error'](_0xa5de('0x1e'),_0x5862dd,_0x4bf21f);_0x1e53a0(_0x4bf21f);});});}function respondWithStatusCode(_0x53849b,_0x217106){_0x217106=_0x217106||0xcc;return function(_0x5c784f){if(_0x5c784f){return _0x53849b[_0xa5de('0x25')](_0x217106);}return _0x53849b[_0xa5de('0x26')](_0x217106)[_0xa5de('0x27')]();};}function respondWithResult(_0x1f2fce,_0xc13345){_0xc13345=_0xc13345||0xc8;return function(_0x59ed52){if(_0x59ed52){return _0x1f2fce[_0xa5de('0x26')](_0xc13345)[_0xa5de('0x28')](_0x59ed52);}};}function respondWithFilteredResult(_0x222a7a,_0x20d6ab){return function(_0x4cbca4){if(_0x4cbca4){var _0x4611ae=typeof _0x20d6ab[_0xa5de('0x29')]===_0xa5de('0x2a')&&typeof _0x20d6ab[_0xa5de('0x2b')]===_0xa5de('0x2a');var _0x4f7078=_0x4cbca4[_0xa5de('0x2c')];var _0x1ba933=_0x4611ae?0x0:_0x20d6ab[_0xa5de('0x29')];var _0x2b2da0=_0x4611ae?_0x4cbca4['count']:_0x20d6ab['offset']+_0x20d6ab[_0xa5de('0x2b')];var _0x4798ea;if(_0x2b2da0>=_0x4f7078){_0x2b2da0=_0x4f7078;_0x4798ea=0xc8;}else{_0x4798ea=0xce;}_0x222a7a[_0xa5de('0x26')](_0x4798ea);return _0x222a7a[_0xa5de('0x2d')](_0xa5de('0x2e'),_0x1ba933+'-'+_0x2b2da0+'/'+_0x4f7078)['json'](_0x4cbca4);}return null;};}function patchUpdates(_0x15db00){return function(_0x300084){try{jsonpatch[_0xa5de('0x2f')](_0x300084,_0x15db00,!![]);}catch(_0x18f001){return BPromise[_0xa5de('0x30')](_0x18f001);}return _0x300084['save']();};}function saveUpdates(_0x40695a,_0x4b9423){return function(_0x4de33a){if(_0x4de33a){return _0x4de33a['update'](_0x40695a)['then'](function(_0x486a64){return _0x486a64;});}return null;};}function removeEntity(_0x562781,_0x55b822){return function(_0x304684){if(_0x304684){return _0x304684['destroy']()[_0xa5de('0x31')](function(){_0x562781['status'](0xcc)[_0xa5de('0x27')]();});}};}function handleEntityNotFound(_0x23ad4b,_0x42775b){return function(_0xc2d5b8){if(!_0xc2d5b8){_0x23ad4b[_0xa5de('0x25')](0x194);}return _0xc2d5b8;};}function handleError(_0x5cdc9d,_0x3f2ab2){_0x3f2ab2=_0x3f2ab2||0x1f4;return function(_0x21de8e){logger[_0xa5de('0x22')](_0x21de8e['stack']);if(_0x21de8e[_0xa5de('0x32')]){delete _0x21de8e[_0xa5de('0x32')];}_0x5cdc9d['status'](_0x3f2ab2)[_0xa5de('0x33')](_0x21de8e);};}exports[_0xa5de('0x34')]=function(_0x231b91,_0x5b5199){var _0xebd4ad={},_0x216a40={},_0x2f7bb3={'count':0x0,'rows':[]};var _0x4d1f01=_['map'](db[_0xa5de('0x35')][_0xa5de('0x36')],function(_0x2bda4c){return{'name':_0x2bda4c[_0xa5de('0x37')],'type':_0x2bda4c[_0xa5de('0x38')]['key']};});_0x216a40[_0xa5de('0x39')]=_[_0xa5de('0x3a')](_0x4d1f01,_0xa5de('0x32'));_0x216a40['query']=_[_0xa5de('0x3b')](_0x231b91[_0xa5de('0x3c')]);_0x216a40[_0xa5de('0x3d')]=_[_0xa5de('0x3e')](_0x216a40[_0xa5de('0x39')],_0x216a40[_0xa5de('0x3c')]);_0xebd4ad[_0xa5de('0x3f')]=_[_0xa5de('0x3e')](_0x216a40[_0xa5de('0x39')],qs[_0xa5de('0x40')](_0x231b91[_0xa5de('0x3c')]['fields']));_0xebd4ad[_0xa5de('0x3f')]=_0xebd4ad['attributes'][_0xa5de('0x41')]?_0xebd4ad[_0xa5de('0x3f')]:_0x216a40[_0xa5de('0x39')];if(!_0x231b91[_0xa5de('0x3c')]['hasOwnProperty'](_0xa5de('0x42'))){_0xebd4ad[_0xa5de('0x2b')]=qs['limit'](_0x231b91[_0xa5de('0x3c')]['limit']);_0xebd4ad[_0xa5de('0x29')]=qs[_0xa5de('0x29')](_0x231b91[_0xa5de('0x3c')][_0xa5de('0x29')]);}_0xebd4ad['order']=qs[_0xa5de('0x43')](_0x231b91[_0xa5de('0x3c')][_0xa5de('0x43')]);_0xebd4ad['where']=qs['filters'](_[_0xa5de('0x44')](_0x231b91[_0xa5de('0x3c')],_0x216a40[_0xa5de('0x3d')]),_0x4d1f01);if(_0x231b91[_0xa5de('0x3c')][_0xa5de('0x45')]){_0xebd4ad[_0xa5de('0x46')]=_[_0xa5de('0x47')](_0xebd4ad[_0xa5de('0x46')],{'$or':_['map'](_0x4d1f01,function(_0x43fe8f){if(_0x43fe8f[_0xa5de('0x38')]!=='VIRTUAL'){var _0x3b5ef2={};_0x3b5ef2[_0x43fe8f[_0xa5de('0x32')]]={'$like':'%'+_0x231b91[_0xa5de('0x3c')][_0xa5de('0x45')]+'%'};return _0x3b5ef2;}})});}_0xebd4ad=_[_0xa5de('0x47')]({},_0xebd4ad,_0x231b91[_0xa5de('0x48')]);var _0x435ba3={'where':_0xebd4ad[_0xa5de('0x46')]};return db['SmsMessage'][_0xa5de('0x2c')](_0x435ba3)[_0xa5de('0x31')](function(_0x49b9e3){_0x2f7bb3['count']=_0x49b9e3;if(_0x231b91[_0xa5de('0x3c')][_0xa5de('0x49')]){_0xebd4ad['include']=[{'all':!![]}];}return db['SmsMessage'][_0xa5de('0x4a')](_0xebd4ad);})[_0xa5de('0x31')](function(_0x2780b5){_0x2f7bb3['rows']=_0x2780b5;return _0x2f7bb3;})[_0xa5de('0x31')](respondWithFilteredResult(_0x5b5199,_0xebd4ad))['catch'](handleError(_0x5b5199,null));};exports['show']=function(_0x54450f,_0x3eea46){var _0x13af0b={'raw':!![],'where':{'id':_0x54450f['params']['id']}},_0x10b21a={};_0x10b21a[_0xa5de('0x39')]=_[_0xa5de('0x3b')](db[_0xa5de('0x35')][_0xa5de('0x36')]);_0x10b21a[_0xa5de('0x3c')]=_['keys'](_0x54450f[_0xa5de('0x3c')]);_0x10b21a['filters']=_[_0xa5de('0x3e')](_0x10b21a[_0xa5de('0x39')],_0x10b21a['query']);_0x13af0b[_0xa5de('0x3f')]=_[_0xa5de('0x3e')](_0x10b21a[_0xa5de('0x39')],qs['fields'](_0x54450f['query'][_0xa5de('0x40')]));_0x13af0b[_0xa5de('0x3f')]=_0x13af0b['attributes'][_0xa5de('0x41')]?_0x13af0b['attributes']:_0x10b21a[_0xa5de('0x39')];if(_0x54450f[_0xa5de('0x3c')][_0xa5de('0x49')]){_0x13af0b[_0xa5de('0x4b')]=[{'all':!![]}];}_0x13af0b=_[_0xa5de('0x47')]({},_0x13af0b,_0x54450f[_0xa5de('0x48')]);return db[_0xa5de('0x35')][_0xa5de('0x4c')](_0x13af0b)[_0xa5de('0x31')](handleEntityNotFound(_0x3eea46,null))[_0xa5de('0x31')](respondWithResult(_0x3eea46,null))['catch'](handleError(_0x3eea46,null));};exports['create']=function(_0x216a49,_0x1e044a){return db[_0xa5de('0x35')][_0xa5de('0x4d')](_0x216a49[_0xa5de('0x4e')],{})[_0xa5de('0x31')](respondWithResult(_0x1e044a,0xc9))[_0xa5de('0x24')](handleError(_0x1e044a,null));};exports['update']=function(_0x3cd9dc,_0x2e24c0){if(_0x3cd9dc[_0xa5de('0x4e')]['id']){delete _0x3cd9dc[_0xa5de('0x4e')]['id'];}return db[_0xa5de('0x35')][_0xa5de('0x4c')]({'where':{'id':_0x3cd9dc[_0xa5de('0x4f')]['id']}})['then'](handleEntityNotFound(_0x2e24c0,null))['then'](saveUpdates(_0x3cd9dc[_0xa5de('0x4e')],null))[_0xa5de('0x31')](respondWithResult(_0x2e24c0,null))[_0xa5de('0x24')](handleError(_0x2e24c0,null));};exports[_0xa5de('0x50')]=function(_0x1f7d4b,_0x1fe1e4){return db[_0xa5de('0x35')]['find']({'where':{'id':_0x1f7d4b[_0xa5de('0x4f')]['id']}})[_0xa5de('0x31')](handleEntityNotFound(_0x1fe1e4,null))[_0xa5de('0x31')](removeEntity(_0x1fe1e4,null))[_0xa5de('0x24')](handleError(_0x1fe1e4,null));};exports[_0xa5de('0x51')]=function(_0x5dfbb5,_0xefd071){return db[_0xa5de('0x35')][_0xa5de('0x51')]()[_0xa5de('0x31')](respondWithResult(_0xefd071,null))[_0xa5de('0x24')](handleError(_0xefd071,null));};var interaction_log=require(_0xa5de('0x13'))(_0xa5de('0x52'));exports[_0xa5de('0x53')]=function(_0xb8752e,_0x4614fc,_0x57a00e){var _0x5d51c6={'agent':{},'channel':_0xa5de('0x54')};if(_0xb8752e[_0xa5de('0x4e')]['id']){delete _0xb8752e[_0xa5de('0x4e')]['id'];}_0xb8752e[_0xa5de('0x4e')][_0xa5de('0x55')]=!![];_0xb8752e[_0xa5de('0x4e')]['readAt']=moment()[_0xa5de('0x56')](_0xa5de('0x57'));_0xb8752e['body'][_0xa5de('0x58')]=_0xb8752e[_0xa5de('0x4e')]['UserId']||_0xb8752e[_0xa5de('0x59')]['id'];_0x5d51c6[_0xa5de('0x5a')]['id']=_0xb8752e[_0xa5de('0x4e')][_0xa5de('0x58')];return db[_0xa5de('0x35')][_0xa5de('0x4c')]({'where':{'id':_0xb8752e['params']['id'],'UserId':null},'include':[{'model':db[_0xa5de('0x5b')],'as':_0xa5de('0x5c')}]})[_0xa5de('0x31')](handleEntityNotFound(_0x4614fc,null))[_0xa5de('0x31')](saveUpdates(_0xb8752e[_0xa5de('0x4e')],null))[_0xa5de('0x31')](function(_0x2b8c1a){if(_0x2b8c1a){_0x5d51c6[_0xa5de('0x23')]=_0x2b8c1a[_0xa5de('0x5d')]({'plain':!![]});return db[_0xa5de('0x5e')][_0xa5de('0x4c')]({'where':{'id':_0x2b8c1a['SmsInteractionId']}});}return null;})[_0xa5de('0x31')](handleEntityNotFound(_0x4614fc,null))[_0xa5de('0x31')](function(_0x9c427){if(_0x9c427){return _0x9c427['update']({'UserId':_0xb8752e['body']['UserId'],'read1stAt':_[_0xa5de('0x5f')](_0x9c427[_0xa5de('0x60')])?moment()[_0xa5de('0x56')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0xa5de('0x31')](function(_0x393b42){if(_0x393b42){_0x5d51c6['interaction']=_0x393b42[_0xa5de('0x5d')]({'plain':!![]});interaction_log['info']('[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0xb8752e[_0xa5de('0x59')]['id'],_0xb8752e[_0xa5de('0x59')][_0xa5de('0x32')],_0xb8752e[_0xa5de('0x59')][_0xa5de('0x61')],_0x5d51c6[_0xa5de('0x62')]['id'],_0xb8752e[_0xa5de('0x4e')]?JSON['stringify'](_0xb8752e[_0xa5de('0x4e')]):_0xa5de('0x63'));return respondWithRpcPromise(_0xa5de('0x64'),_0xa5de('0x65'),_0x5d51c6);}return null;})[_0xa5de('0x31')](function(_0x56f798){if(_0x56f798){if(_0xb8752e[_0xa5de('0x4e')][_0xa5de('0x66')]){_0x5d51c6[_0xa5de('0x23')][_0xa5de('0x67')]=util[_0xa5de('0x56')](_0xa5de('0x68'),_0xb8752e[_0xa5de('0x59')][_0xa5de('0x32')]);_0x5d51c6[_0xa5de('0x23')][_0xa5de('0x69')]=_0x5d51c6[_0xa5de('0x69')];_0x5d51c6[_0xa5de('0x23')][_0xa5de('0x6a')]='accept';return respondWithRpcPromise('EventManager','EventManager',{'event':_0xa5de('0x6b'),'message':_0x5d51c6['message']},client9002)['then'](function(){return _0x5d51c6;});}return _0x5d51c6;}return null;})[_0xa5de('0x31')](respondWithResult(_0x4614fc,null))[_0xa5de('0x24')](handleError(_0x4614fc,null));};var interaction_log=require(_0xa5de('0x13'))(_0xa5de('0x52'));exports['reject']=function(_0x3a3110,_0x363c2c,_0x2a554b){var _0x4cfa02={'agent':{},'channel':'sms'};if(_0x3a3110[_0xa5de('0x4e')]['id']){delete _0x3a3110[_0xa5de('0x4e')]['id'];}_0x3a3110[_0xa5de('0x4e')][_0xa5de('0x58')]=_0x3a3110[_0xa5de('0x4e')]['UserId']||_0x3a3110[_0xa5de('0x59')]['id'];_0x4cfa02[_0xa5de('0x5a')]['id']=_0x3a3110['body'][_0xa5de('0x58')];return db[_0xa5de('0x35')][_0xa5de('0x4c')]({'where':{'id':_0x3a3110['params']['id'],'UserId':null}})[_0xa5de('0x31')](handleEntityNotFound(_0x363c2c,null))['then'](function(_0x56b14d){if(_0x56b14d){_0x4cfa02[_0xa5de('0x23')]=_0x56b14d[_0xa5de('0x5d')]({'plain':!![]});return db[_0xa5de('0x5e')]['find']({'where':{'id':_0x56b14d['SmsInteractionId']}});}return null;})[_0xa5de('0x31')](handleEntityNotFound(_0x363c2c,null))[_0xa5de('0x31')](function(_0x52068e){if(_0x52068e){_0x4cfa02['interaction']=_0x52068e[_0xa5de('0x5d')]({'plain':!![]});interaction_log[_0xa5de('0x6c')]('[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x3a3110[_0xa5de('0x59')]['id'],_0x3a3110['user'][_0xa5de('0x32')],_0x3a3110[_0xa5de('0x59')][_0xa5de('0x61')],_0x4cfa02[_0xa5de('0x62')]['id'],_0x3a3110['body']?JSON[_0xa5de('0x21')](_0x3a3110['body']):_0xa5de('0x63'));return respondWithRpcPromise(_0xa5de('0x6d'),'rejectMessage',_0x4cfa02);}return null;})[_0xa5de('0x31')](function(_0x1b3ca5){if(_0x1b3ca5){_0x1b3ca5[_0xa5de('0x23')]['interface']=util['format'](_0xa5de('0x68'),_0x3a3110[_0xa5de('0x59')][_0xa5de('0x32')]);_0x1b3ca5[_0xa5de('0x23')][_0xa5de('0x69')]=_0x4cfa02[_0xa5de('0x69')];_0x1b3ca5[_0xa5de('0x23')][_0xa5de('0x6a')]=_0xa5de('0x30');respondWithRpcPromise(_0xa5de('0x6e'),'EventManager',{'event':'rejectmessage','message':_0x1b3ca5[_0xa5de('0x23')]},client9002);return _0x4cfa02;}return null;})[_0xa5de('0x31')](respondWithResult(_0x363c2c,null))['catch'](handleError(_0x363c2c,null));};exports['status']=function(_0x29e5a6,_0x1f61c1,_0x43ab0b){if(_0x29e5a6[_0xa5de('0x4e')]['id']){delete _0x29e5a6[_0xa5de('0x4e')]['id'];}var _0x1227c0;return db[_0xa5de('0x35')]['find']({'where':{'id':_0x29e5a6['params']['id']}})[_0xa5de('0x31')](handleEntityNotFound(_0x1f61c1,null))[_0xa5de('0x31')](function(_0x400b35){if(_0x400b35){_0x1227c0=_0x400b35;return db[_0xa5de('0x6f')]['find']({'where':{'id':_0x400b35[_0xa5de('0x70')]}});}})[_0xa5de('0x31')](handleEntityNotFound(_0x1f61c1,null))[_0xa5de('0x31')](function(_0x196643){if(_0x196643){logger[_0xa5de('0x20')](_0xa5de('0x71'),_0xa5de('0x26'),_0xa5de('0x72'),_0x196643[_0xa5de('0x38')],util[_0xa5de('0x73')](_0x29e5a6[_0xa5de('0x4e')],{'showHidden':![],'depth':null}));switch(_0x196643[_0xa5de('0x38')]){case _0xa5de('0x74'):if(_0x29e5a6[_0xa5de('0x4e')][_0xa5de('0x75')]&&_0x29e5a6[_0xa5de('0x4e')]['MessageSid']===_0x1227c0[_0xa5de('0x76')]){return _0x1227c0[_0xa5de('0x77')]({'read':!![]});}else{logger['error'](_0xa5de('0x78'),_0xa5de('0x26'),_0xa5de('0x74'),util[_0xa5de('0x73')](_0x29e5a6['body'],{'showHidden':![],'depth':null}));}break;case _0xa5de('0x79'):if(_0x29e5a6[_0xa5de('0x4e')][_0xa5de('0x7a')]&&_0x29e5a6[_0xa5de('0x4e')][_0xa5de('0x7a')]===_0x1227c0['messageId']&&_[_0xa5de('0x7b')](['sent',_0xa5de('0x7c')],_0x29e5a6[_0xa5de('0x4e')]['Status'])>=0x0){return _0x1227c0[_0xa5de('0x77')]({'read':!![]});}else{logger[_0xa5de('0x22')](_0xa5de('0x78'),_0xa5de('0x26'),'plivio',util[_0xa5de('0x73')](_0x29e5a6['body'],{'showHidden':![],'depth':null}));}break;case'infobip':var _0xd50177=_0x29e5a6['body'][_0xa5de('0x7d')][0x0];if(_0xd50177[_0xa5de('0x26')][_0xa5de('0x7e')]==='DELIVERED'){return _0x1227c0['update']({'read':!![]});}else{logger[_0xa5de('0x22')](_0xa5de('0x78'),_0xa5de('0x26'),_0xa5de('0x7f'),util['inspect'](_0x29e5a6[_0xa5de('0x4e')],{'showHidden':![],'depth':null}));}break;}return _0x1227c0;}})[_0xa5de('0x31')](respondWithResult(_0x1f61c1,null))['catch'](handleError(_0x1f61c1,null));};
\ No newline at end of file