Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / smsMessage / smsMessage.controller.js
index bed207e..9b94f86 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x26b0=['rejectmessage','SmsAccount','SmsAccountId','debug','SmsMessage,\x20%s,\x20%s,\x20%s','twilio','MessageSid','SmsAccount,\x20%s,\x20%s,\x20%s','inspect','plivo','MessageUUID','messageId','indexOf','sent','delivered','Status','plivio','infobip','results','groupName','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','fs-extra','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./smsMessage.socket','jayson/promise','client','http','SmsMessage,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','end','status','undefined','limit','count','offset','set','Content-Range','json','reject','save','update','then','destroy','sendStatus','name','index','map','SmsMessage','rawAttributes','type','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','sort','filters','pick','filter','where','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','params','find','create','body','sms-interactions','accept','sms','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','SmsInteraction','SmsInteractionId','isNil','interaction','get','[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','Sequelize','SELECT','User','fullname','internal','interface','SIP/%s','channel','motionChannel','event','EventManager','acceptmessage','[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','RejectMessage','rejectMessage','QueryTypes','contact','email'];(function(_0x303c30,_0x16edcb){var _0x43161b=function(_0x3330ff){while(--_0x3330ff){_0x303c30['push'](_0x303c30['shift']());}};_0x43161b(++_0x16edcb);}(_0x26b0,0x138));var _0x026b=function(_0x5d845a,_0x3d3db0){_0x5d845a=_0x5d845a-0x0;var _0x111a7b=_0x26b0[_0x5d845a];return _0x111a7b;};'use strict';var emlformat=require(_0x026b('0x0'));var rimraf=require(_0x026b('0x1'));var zipdir=require(_0x026b('0x2'));var jsonpatch=require(_0x026b('0x3'));var rp=require(_0x026b('0x4'));var moment=require(_0x026b('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x026b('0x6'));var util=require(_0x026b('0x7'));var path=require(_0x026b('0x8'));var sox=require(_0x026b('0x9'));var csv=require(_0x026b('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x026b('0xb'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x026b('0xc'));var deskjs=require(_0x026b('0xd'));var toCsv=require(_0x026b('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x026b('0xe'));var authService=require(_0x026b('0xf'));var qs=require(_0x026b('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x026b('0x11'));var logger=require(_0x026b('0x12'))(_0x026b('0x13'));var utils=require(_0x026b('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x026b('0x15'));var db=require(_0x026b('0x16'))['db'];config[_0x026b('0x17')]=_[_0x026b('0x18')](config[_0x026b('0x17')],{'host':_0x026b('0x19'),'port':0x18eb});var socket=require(_0x026b('0x1a'))(new Redis(config['redis']));require(_0x026b('0x1b'))['register'](socket);var jayson=require(_0x026b('0x1c'));var client=jayson[_0x026b('0x1d')][_0x026b('0x1e')]({'port':0x232c});var client9002=jayson[_0x026b('0x1d')]['http']({'port':0x232a});function respondWithRpcPromise(_0x250697,_0x1956a4,_0xe8d12,_0x4c0fca){return new BPromise(function(_0x5117f3,_0x4bd1ff){var _0x43b1a8=_0x4c0fca||client;return _0x43b1a8['request'](_0x250697,_0xe8d12)['then'](function(_0xbb0e24){logger['info'](_0x026b('0x1f'),_0x1956a4,_0x026b('0x20'));logger['debug']('SmsMessage,\x20%s,\x20%s,\x20%s',_0x1956a4,_0x026b('0x20'),JSON[_0x026b('0x21')](_0xbb0e24));if(_0xbb0e24[_0x026b('0x22')]){if(_0xbb0e24[_0x026b('0x22')][_0x026b('0x23')]===0x1f4){logger['error'](_0x026b('0x1f'),_0x1956a4,_0xbb0e24[_0x026b('0x22')][_0x026b('0x24')]);return _0x4bd1ff(_0xbb0e24['error'][_0x026b('0x24')]);}logger[_0x026b('0x22')](_0x026b('0x1f'),_0x1956a4,_0xbb0e24[_0x026b('0x22')][_0x026b('0x24')]);return _0x5117f3(_0xbb0e24['error'][_0x026b('0x24')]);}else{logger[_0x026b('0x25')](_0x026b('0x1f'),_0x1956a4,_0x026b('0x20'));_0x5117f3(_0xbb0e24[_0x026b('0x26')][_0x026b('0x24')]);}})['catch'](function(_0x4b42b9){logger[_0x026b('0x22')]('SmsMessage,\x20%s,\x20%s',_0x1956a4,_0x4b42b9);_0x4bd1ff(_0x4b42b9);});});}function respondWithStatusCode(_0x27cb59,_0x19b1dc){_0x19b1dc=_0x19b1dc||0xcc;return function(_0x39f344){if(_0x39f344){return _0x27cb59['sendStatus'](_0x19b1dc);}return _0x27cb59['status'](_0x19b1dc)[_0x026b('0x27')]();};}function respondWithResult(_0x3f3999,_0x472191){_0x472191=_0x472191||0xc8;return function(_0x382e51){if(_0x382e51){return _0x3f3999[_0x026b('0x28')](_0x472191)['json'](_0x382e51);}};}function respondWithFilteredResult(_0x2ab365,_0x335463){return function(_0x464667){if(_0x464667){var _0x2bb89f=typeof _0x335463['offset']===_0x026b('0x29')&&typeof _0x335463[_0x026b('0x2a')]==='undefined';var _0x59e9b2=_0x464667[_0x026b('0x2b')];var _0x34fbba=_0x2bb89f?0x0:_0x335463['offset'];var _0x5b9edf=_0x2bb89f?_0x464667['count']:_0x335463[_0x026b('0x2c')]+_0x335463['limit'];var _0x33590f;if(_0x5b9edf>=_0x59e9b2){_0x5b9edf=_0x59e9b2;_0x33590f=0xc8;}else{_0x33590f=0xce;}_0x2ab365[_0x026b('0x28')](_0x33590f);return _0x2ab365[_0x026b('0x2d')](_0x026b('0x2e'),_0x34fbba+'-'+_0x5b9edf+'/'+_0x59e9b2)[_0x026b('0x2f')](_0x464667);}return null;};}function patchUpdates(_0x17bc65){return function(_0x421f43){try{jsonpatch['apply'](_0x421f43,_0x17bc65,!![]);}catch(_0x2d8002){return BPromise[_0x026b('0x30')](_0x2d8002);}return _0x421f43[_0x026b('0x31')]();};}function saveUpdates(_0x5a3781,_0x54df5a){return function(_0x283a18){if(_0x283a18){return _0x283a18[_0x026b('0x32')](_0x5a3781)[_0x026b('0x33')](function(_0x25e02c){return _0x25e02c;});}return null;};}function removeEntity(_0x48fe1c,_0x22d5c6){return function(_0x3ee3dd){if(_0x3ee3dd){return _0x3ee3dd[_0x026b('0x34')]()[_0x026b('0x33')](function(){_0x48fe1c['status'](0xcc)[_0x026b('0x27')]();});}};}function handleEntityNotFound(_0xa3adae,_0x685abe){return function(_0x163dff){if(!_0x163dff){_0xa3adae[_0x026b('0x35')](0x194);}return _0x163dff;};}function handleError(_0xab6df2,_0x862d33){_0x862d33=_0x862d33||0x1f4;return function(_0x339b59){logger[_0x026b('0x22')](_0x339b59['stack']);if(_0x339b59[_0x026b('0x36')]){delete _0x339b59[_0x026b('0x36')];}_0xab6df2[_0x026b('0x28')](_0x862d33)['send'](_0x339b59);};}exports[_0x026b('0x37')]=function(_0x1105cf,_0x3c8d55){var _0x30e072={},_0x27e29d={},_0x400c6f={'count':0x0,'rows':[]};var _0x5bb124=_[_0x026b('0x38')](db[_0x026b('0x39')][_0x026b('0x3a')],function(_0x5811e7){return{'name':_0x5811e7['fieldName'],'type':_0x5811e7[_0x026b('0x3b')]['key']};});_0x27e29d[_0x026b('0x3c')]=_['map'](_0x5bb124,_0x026b('0x36'));_0x27e29d[_0x026b('0x3d')]=_[_0x026b('0x3e')](_0x1105cf[_0x026b('0x3d')]);_0x27e29d['filters']=_[_0x026b('0x3f')](_0x27e29d[_0x026b('0x3c')],_0x27e29d[_0x026b('0x3d')]);_0x30e072[_0x026b('0x40')]=_['intersection'](_0x27e29d[_0x026b('0x3c')],qs[_0x026b('0x41')](_0x1105cf[_0x026b('0x3d')]['fields']));_0x30e072[_0x026b('0x40')]=_0x30e072[_0x026b('0x40')][_0x026b('0x42')]?_0x30e072[_0x026b('0x40')]:_0x27e29d[_0x026b('0x3c')];if(!_0x1105cf[_0x026b('0x3d')][_0x026b('0x43')]('nolimit')){_0x30e072[_0x026b('0x2a')]=qs[_0x026b('0x2a')](_0x1105cf[_0x026b('0x3d')][_0x026b('0x2a')]);_0x30e072[_0x026b('0x2c')]=qs[_0x026b('0x2c')](_0x1105cf[_0x026b('0x3d')]['offset']);}_0x30e072['order']=qs[_0x026b('0x44')](_0x1105cf['query'][_0x026b('0x44')]);_0x30e072['where']=qs[_0x026b('0x45')](_[_0x026b('0x46')](_0x1105cf[_0x026b('0x3d')],_0x27e29d[_0x026b('0x45')]),_0x5bb124);if(_0x1105cf[_0x026b('0x3d')][_0x026b('0x47')]){_0x30e072['where']=_['merge'](_0x30e072[_0x026b('0x48')],{'$or':_[_0x026b('0x38')](_0x5bb124,function(_0x300660){if(_0x300660[_0x026b('0x3b')]!==_0x026b('0x49')){var _0x197847={};_0x197847[_0x300660['name']]={'$like':'%'+_0x1105cf[_0x026b('0x3d')][_0x026b('0x47')]+'%'};return _0x197847;}})});}_0x30e072=_[_0x026b('0x4a')]({},_0x30e072,_0x1105cf[_0x026b('0x4b')]);var _0x4eb458={'where':_0x30e072[_0x026b('0x48')]};return db[_0x026b('0x39')]['count'](_0x4eb458)[_0x026b('0x33')](function(_0x1773eb){_0x400c6f[_0x026b('0x2b')]=_0x1773eb;if(_0x1105cf['query'][_0x026b('0x4c')]){_0x30e072[_0x026b('0x4d')]=[{'all':!![]}];}return db[_0x026b('0x39')][_0x026b('0x4e')](_0x30e072);})[_0x026b('0x33')](function(_0x50ef6f){_0x400c6f[_0x026b('0x4f')]=_0x50ef6f;return _0x400c6f;})[_0x026b('0x33')](respondWithFilteredResult(_0x3c8d55,_0x30e072))[_0x026b('0x50')](handleError(_0x3c8d55,null));};exports['show']=function(_0x43b296,_0x4a3028){var _0x40d424={'raw':!![],'where':{'id':_0x43b296[_0x026b('0x51')]['id']}},_0x2ccc79={};_0x2ccc79[_0x026b('0x3c')]=_[_0x026b('0x3e')](db[_0x026b('0x39')][_0x026b('0x3a')]);_0x2ccc79[_0x026b('0x3d')]=_[_0x026b('0x3e')](_0x43b296[_0x026b('0x3d')]);_0x2ccc79['filters']=_[_0x026b('0x3f')](_0x2ccc79[_0x026b('0x3c')],_0x2ccc79[_0x026b('0x3d')]);_0x40d424['attributes']=_[_0x026b('0x3f')](_0x2ccc79[_0x026b('0x3c')],qs[_0x026b('0x41')](_0x43b296[_0x026b('0x3d')][_0x026b('0x41')]));_0x40d424['attributes']=_0x40d424[_0x026b('0x40')][_0x026b('0x42')]?_0x40d424[_0x026b('0x40')]:_0x2ccc79[_0x026b('0x3c')];if(_0x43b296[_0x026b('0x3d')][_0x026b('0x4c')]){_0x40d424[_0x026b('0x4d')]=[{'all':!![]}];}_0x40d424=_[_0x026b('0x4a')]({},_0x40d424,_0x43b296[_0x026b('0x4b')]);return db[_0x026b('0x39')][_0x026b('0x52')](_0x40d424)['then'](handleEntityNotFound(_0x4a3028,null))[_0x026b('0x33')](respondWithResult(_0x4a3028,null))[_0x026b('0x50')](handleError(_0x4a3028,null));};exports[_0x026b('0x53')]=function(_0x5bb329,_0x495425){return db[_0x026b('0x39')][_0x026b('0x53')](_0x5bb329[_0x026b('0x54')],{})['then'](respondWithResult(_0x495425,0xc9))['catch'](handleError(_0x495425,null));};exports[_0x026b('0x32')]=function(_0x3f8b13,_0xc3bcd0){if(_0x3f8b13[_0x026b('0x54')]['id']){delete _0x3f8b13['body']['id'];}return db[_0x026b('0x39')][_0x026b('0x52')]({'where':{'id':_0x3f8b13['params']['id']}})[_0x026b('0x33')](handleEntityNotFound(_0xc3bcd0,null))[_0x026b('0x33')](saveUpdates(_0x3f8b13[_0x026b('0x54')],null))['then'](respondWithResult(_0xc3bcd0,null))[_0x026b('0x50')](handleError(_0xc3bcd0,null));};exports['destroy']=function(_0x3334e6,_0x416475){return db['SmsMessage'][_0x026b('0x52')]({'where':{'id':_0x3334e6[_0x026b('0x51')]['id']}})['then'](handleEntityNotFound(_0x416475,null))[_0x026b('0x33')](removeEntity(_0x416475,null))[_0x026b('0x50')](handleError(_0x416475,null));};exports['describe']=function(_0x422e38,_0x813477){return db[_0x026b('0x39')]['describe']()[_0x026b('0x33')](respondWithResult(_0x813477,null))[_0x026b('0x50')](handleError(_0x813477,null));};var interaction_log=require(_0x026b('0x12'))(_0x026b('0x55'));exports[_0x026b('0x56')]=function(_0x45b74f,_0x424588,_0x2b64ce){var _0x30a887={'agent':{},'channel':_0x026b('0x57')};if(_0x45b74f[_0x026b('0x54')]['id']){delete _0x45b74f[_0x026b('0x54')]['id'];}_0x45b74f[_0x026b('0x54')][_0x026b('0x58')]=!![];_0x45b74f[_0x026b('0x54')][_0x026b('0x59')]=moment()[_0x026b('0x5a')](_0x026b('0x5b'));_0x45b74f['body']['UserId']=_0x45b74f[_0x026b('0x54')][_0x026b('0x5c')]||_0x45b74f[_0x026b('0x5d')]['id'];_0x30a887[_0x026b('0x5e')]['id']=_0x45b74f[_0x026b('0x54')][_0x026b('0x5c')];return db[_0x026b('0x39')][_0x026b('0x52')]({'where':{'id':_0x45b74f[_0x026b('0x51')]['id'],'UserId':null}})[_0x026b('0x33')](handleEntityNotFound(_0x424588,null))[_0x026b('0x33')](saveUpdates(_0x45b74f['body'],null))[_0x026b('0x33')](function(_0x5e32a1){if(_0x5e32a1){_0x30a887[_0x026b('0x24')]=_0x5e32a1['get']({'plain':!![]});return db[_0x026b('0x5f')][_0x026b('0x52')]({'where':{'id':_0x5e32a1[_0x026b('0x60')]}});}return null;})[_0x026b('0x33')](handleEntityNotFound(_0x424588,null))[_0x026b('0x33')](function(_0x2e8e42){if(_0x2e8e42){return _0x2e8e42[_0x026b('0x32')]({'UserId':_0x45b74f[_0x026b('0x54')][_0x026b('0x5c')],'read1stAt':_[_0x026b('0x61')](_0x2e8e42['read1stAt'])?moment()[_0x026b('0x5a')](_0x026b('0x5b')):undefined});}return null;})['then'](function(_0x391a69){if(_0x391a69){_0x30a887[_0x026b('0x62')]=_0x391a69[_0x026b('0x63')]({'plain':!![]});interaction_log[_0x026b('0x25')](_0x026b('0x64'),_0x45b74f['user']['id'],_0x45b74f[_0x026b('0x5d')]['name'],_0x45b74f[_0x026b('0x5d')]['role'],_0x30a887[_0x026b('0x62')]['id'],_0x45b74f[_0x026b('0x54')]?JSON['stringify'](_0x45b74f[_0x026b('0x54')]):'null');return respondWithRpcPromise(_0x026b('0x65'),_0x026b('0x66'),_0x30a887);}return null;})[_0x026b('0x33')](function(_0x453445){var _0x5c5023=_0x026b('0x67')+_0x453445[_0x026b('0x24')][_0x026b('0x68')];return db[_0x026b('0x69')][_0x026b('0x3d')](_0x5c5023,{'type':db[_0x026b('0x6a')]['QueryTypes'][_0x026b('0x6b')],'raw':!![]})[_0x026b('0x33')](function(_0x119483){return _0x119483;});})[_0x026b('0x33')](function(_0x35baf2){if(_0x35baf2){_0x30a887[_0x026b('0x24')]['contact']=_0x35baf2[0x0];if(!_0x45b74f[_0x026b('0x54')]['UserId'])return;return db[_0x026b('0x6c')][_0x026b('0x52')]({'where':{'id':_0x45b74f['body']['UserId'],'role':_0x026b('0x5e')},'attributes':['id',_0x026b('0x36'),_0x026b('0x6d'),'email',_0x026b('0x6e')],'raw':!![]});}return null;})['then'](function(_0x5b5875){if(!_0x5b5875)return null;_0x30a887['message'][_0x026b('0x5e')]=_0x5b5875;return _0x30a887;})[_0x026b('0x33')](function(_0xd798ac){if(_0xd798ac){if(_0x45b74f[_0x026b('0x54')]['manual']){_0x30a887[_0x026b('0x24')][_0x026b('0x6f')]=util[_0x026b('0x5a')](_0x026b('0x70'),_0x45b74f[_0x026b('0x5d')][_0x026b('0x36')]);_0x30a887['message']['channel']=_0x30a887[_0x026b('0x71')];_0x30a887[_0x026b('0x24')][_0x026b('0x72')]=_0x30a887[_0x026b('0x71')];_0x30a887['message'][_0x026b('0x73')]=_0x026b('0x56');return respondWithRpcPromise(_0x026b('0x74'),_0x026b('0x74'),{'event':_0x026b('0x75'),'message':_0x30a887[_0x026b('0x24')]},client9002)[_0x026b('0x33')](function(){return _0x30a887;});}return _0x30a887;}return null;})[_0x026b('0x33')](respondWithResult(_0x424588,null))[_0x026b('0x50')](handleError(_0x424588,null));};var interaction_log=require('../../config/logger')(_0x026b('0x55'));exports[_0x026b('0x30')]=function(_0x525ea8,_0x52cb12,_0x30d002){var _0x5a5ee3={'agent':{},'channel':'sms'};if(_0x525ea8[_0x026b('0x54')]['id']){delete _0x525ea8[_0x026b('0x54')]['id'];}_0x525ea8[_0x026b('0x54')][_0x026b('0x5c')]=_0x525ea8[_0x026b('0x54')]['UserId']||_0x525ea8['user']['id'];_0x5a5ee3[_0x026b('0x5e')]['id']=_0x525ea8[_0x026b('0x54')]['UserId'];return db[_0x026b('0x39')][_0x026b('0x52')]({'where':{'id':_0x525ea8[_0x026b('0x51')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x52cb12,null))[_0x026b('0x33')](function(_0x1c61f2){if(_0x1c61f2){_0x5a5ee3['message']=_0x1c61f2[_0x026b('0x63')]({'plain':!![]});return db[_0x026b('0x5f')][_0x026b('0x52')]({'where':{'id':_0x1c61f2[_0x026b('0x60')]}});}return null;})[_0x026b('0x33')](handleEntityNotFound(_0x52cb12,null))['then'](function(_0x5ec571){if(_0x5ec571){_0x5a5ee3[_0x026b('0x62')]=_0x5ec571[_0x026b('0x63')]({'plain':!![]});interaction_log[_0x026b('0x25')](_0x026b('0x76'),_0x525ea8[_0x026b('0x5d')]['id'],_0x525ea8['user']['name'],_0x525ea8[_0x026b('0x5d')][_0x026b('0x77')],_0x5a5ee3['interaction']['id'],_0x525ea8[_0x026b('0x54')]?JSON['stringify'](_0x525ea8[_0x026b('0x54')]):_0x026b('0x78'));return respondWithRpcPromise(_0x026b('0x79'),_0x026b('0x7a'),_0x5a5ee3);}return null;})[_0x026b('0x33')](function(_0x13883a){var _0x349ff8=_0x026b('0x67')+_0x13883a[_0x026b('0x24')][_0x026b('0x68')];return db[_0x026b('0x69')][_0x026b('0x3d')](_0x349ff8,{'type':db[_0x026b('0x6a')][_0x026b('0x7b')][_0x026b('0x6b')],'raw':!![]})[_0x026b('0x33')](function(_0x14272a){return _0x14272a;});})['then'](function(_0x31a8e8){if(_0x31a8e8){_0x5a5ee3[_0x026b('0x24')][_0x026b('0x7c')]=_0x31a8e8[0x0];if(!_0x525ea8[_0x026b('0x54')][_0x026b('0x5c')])return;return db['User']['find']({'where':{'id':_0x525ea8['body']['UserId'],'role':_0x026b('0x5e')},'attributes':['id',_0x026b('0x36'),_0x026b('0x6d'),_0x026b('0x7d'),_0x026b('0x6e')],'raw':!![]});}return null;})[_0x026b('0x33')](function(_0x31f6f3){if(!_0x31f6f3)return null;_0x5a5ee3[_0x026b('0x24')]['agent']=_0x31f6f3;return _0x5a5ee3;})[_0x026b('0x33')](function(_0x287e03){if(_0x287e03){_0x287e03['message'][_0x026b('0x6f')]=util[_0x026b('0x5a')](_0x026b('0x70'),_0x525ea8['user'][_0x026b('0x36')]);_0x287e03[_0x026b('0x24')][_0x026b('0x71')]=_0x5a5ee3[_0x026b('0x71')];_0x287e03[_0x026b('0x24')][_0x026b('0x72')]=_0x5a5ee3['channel'];_0x287e03[_0x026b('0x24')][_0x026b('0x73')]=_0x026b('0x30');respondWithRpcPromise(_0x026b('0x74'),_0x026b('0x74'),{'event':_0x026b('0x7e'),'message':_0x287e03[_0x026b('0x24')]},client9002);return _0x5a5ee3;}return null;})[_0x026b('0x33')](respondWithResult(_0x52cb12,null))[_0x026b('0x50')](handleError(_0x52cb12,null));};exports[_0x026b('0x28')]=function(_0x578af5,_0x32f151,_0x5a779e){if(_0x578af5[_0x026b('0x54')]['id']){delete _0x578af5[_0x026b('0x54')]['id'];}var _0x269f9c;return db[_0x026b('0x39')][_0x026b('0x52')]({'where':{'id':_0x578af5[_0x026b('0x51')]['id']}})[_0x026b('0x33')](handleEntityNotFound(_0x32f151,null))[_0x026b('0x33')](function(_0x4928eb){if(_0x4928eb){_0x269f9c=_0x4928eb;return db[_0x026b('0x7f')][_0x026b('0x52')]({'where':{'id':_0x4928eb[_0x026b('0x80')]}});}})[_0x026b('0x33')](handleEntityNotFound(_0x32f151,null))[_0x026b('0x33')](function(_0x41722c){if(_0x41722c){logger[_0x026b('0x81')](_0x026b('0x82'),_0x026b('0x28'),'received\x20delivery\x20report\x20from',_0x41722c[_0x026b('0x3b')],util['inspect'](_0x578af5[_0x026b('0x54')],{'showHidden':![],'depth':null}));switch(_0x41722c[_0x026b('0x3b')]){case _0x026b('0x83'):if(_0x578af5['body'][_0x026b('0x84')]&&_0x578af5[_0x026b('0x54')]['MessageSid']===_0x269f9c['messageId']){return _0x269f9c['update']({'read':!![]});}else{logger['error'](_0x026b('0x85'),_0x026b('0x28'),'twilio',util[_0x026b('0x86')](_0x578af5[_0x026b('0x54')],{'showHidden':![],'depth':null}));}break;case _0x026b('0x87'):if(_0x578af5[_0x026b('0x54')][_0x026b('0x88')]&&_0x578af5[_0x026b('0x54')][_0x026b('0x88')]===_0x269f9c[_0x026b('0x89')]&&_[_0x026b('0x8a')]([_0x026b('0x8b'),_0x026b('0x8c')],_0x578af5[_0x026b('0x54')][_0x026b('0x8d')])>=0x0){return _0x269f9c[_0x026b('0x32')]({'read':!![]});}else{logger['error'](_0x026b('0x85'),_0x026b('0x28'),_0x026b('0x8e'),util[_0x026b('0x86')](_0x578af5['body'],{'showHidden':![],'depth':null}));}break;case _0x026b('0x8f'):var _0x6d4d2a=_0x578af5[_0x026b('0x54')][_0x026b('0x90')][0x0];if(_0x6d4d2a[_0x026b('0x28')][_0x026b('0x91')]==='DELIVERED'){return _0x269f9c[_0x026b('0x32')]({'read':!![]});}else{logger[_0x026b('0x22')](_0x026b('0x85'),_0x026b('0x28'),_0x026b('0x8f'),util[_0x026b('0x86')](_0x578af5[_0x026b('0x54')],{'showHidden':![],'depth':null}));}break;}return _0x269f9c;}})['then'](respondWithResult(_0x32f151,null))[_0x026b('0x50')](handleError(_0x32f151,null));};
\ No newline at end of file
+var _0xa5c9=['contact','User','motionChannel','event','rejectmessage','SmsAccount','SmsAccountId','received\x20delivery\x20report\x20from','inspect','twilio','MessageSid','messageId','SmsAccount,\x20%s,\x20%s,\x20%s','plivo','MessageUUID','indexOf','sent','Status','results','DELIVERED','infobip','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','to-csv','ejs','fs-extra','lodash','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./smsMessage.socket','register','jayson/promise','http','client','request','then','SmsMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','status','end','json','undefined','count','offset','limit','set','Content-Range','apply','reject','update','destroy','sendStatus','stack','name','map','SmsMessage','rawAttributes','fieldName','type','key','query','keys','filters','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','VIRTUAL','options','includeAll','include','findAll','rows','show','merge','find','create','body','params','describe','sms-interactions','accept','sms','read','readAt','YYYY-MM-DD\x20HH:mm:ss','user','UserId','get','SmsInteraction','SmsInteractionId','isNil','read1stAt','format','interaction','[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','AcceptMessage','acceptMessage','ContactId','sequelize','Sequelize','SELECT','agent','fullname','email','internal','interface','SIP/%s','channel','EventManager','acceptmessage','[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','QueryTypes'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xa5c9,0x143));var _0x9a5c=function(_0x20589d,_0x55d5bf){_0x20589d=_0x20589d-0x0;var _0x422de9=_0xa5c9[_0x20589d];return _0x422de9;};'use strict';var emlformat=require(_0x9a5c('0x0'));var rimraf=require(_0x9a5c('0x1'));var zipdir=require(_0x9a5c('0x2'));var jsonpatch=require(_0x9a5c('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x9a5c('0x4'));var Mustache=require(_0x9a5c('0x5'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x9a5c('0x6'));var ejs=require(_0x9a5c('0x7'));var fs=require('fs');var fs_extra=require(_0x9a5c('0x8'));var _=require(_0x9a5c('0x9'));var squel=require('squel');var crypto=require(_0x9a5c('0xa'));var jsforce=require('jsforce');var deskjs=require(_0x9a5c('0xb'));var toCsv=require(_0x9a5c('0x6'));var querystring=require('querystring');var Papa=require(_0x9a5c('0xc'));var Redis=require(_0x9a5c('0xd'));var authService=require(_0x9a5c('0xe'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9a5c('0xf'));var logger=require(_0x9a5c('0x10'))(_0x9a5c('0x11'));var utils=require(_0x9a5c('0x12'));var config=require(_0x9a5c('0x13'));var licenseUtil=require(_0x9a5c('0x14'));var db=require(_0x9a5c('0x15'))['db'];config[_0x9a5c('0x16')]=_[_0x9a5c('0x17')](config[_0x9a5c('0x16')],{'host':_0x9a5c('0x18'),'port':0x18eb});var socket=require(_0x9a5c('0x19'))(new Redis(config['redis']));require(_0x9a5c('0x1a'))[_0x9a5c('0x1b')](socket);var jayson=require(_0x9a5c('0x1c'));var client=jayson['client'][_0x9a5c('0x1d')]({'port':0x232c});var client9002=jayson[_0x9a5c('0x1e')]['http']({'port':0x232a});function respondWithRpcPromise(_0x16422d,_0x5ef98e,_0x350bd5,_0x507a12){return new BPromise(function(_0x29d3cd,_0x1e0c41){var _0x59e410=_0x507a12||client;return _0x59e410[_0x9a5c('0x1f')](_0x16422d,_0x350bd5)[_0x9a5c('0x20')](function(_0x39fbea){logger['info'](_0x9a5c('0x21'),_0x5ef98e,_0x9a5c('0x22'));logger[_0x9a5c('0x23')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x5ef98e,_0x9a5c('0x22'),JSON[_0x9a5c('0x24')](_0x39fbea));if(_0x39fbea['error']){if(_0x39fbea[_0x9a5c('0x25')][_0x9a5c('0x26')]===0x1f4){logger[_0x9a5c('0x25')]('SmsMessage,\x20%s,\x20%s',_0x5ef98e,_0x39fbea[_0x9a5c('0x25')][_0x9a5c('0x27')]);return _0x1e0c41(_0x39fbea['error'][_0x9a5c('0x27')]);}logger[_0x9a5c('0x25')]('SmsMessage,\x20%s,\x20%s',_0x5ef98e,_0x39fbea[_0x9a5c('0x25')][_0x9a5c('0x27')]);return _0x29d3cd(_0x39fbea[_0x9a5c('0x25')]['message']);}else{logger[_0x9a5c('0x28')](_0x9a5c('0x21'),_0x5ef98e,_0x9a5c('0x22'));_0x29d3cd(_0x39fbea[_0x9a5c('0x29')][_0x9a5c('0x27')]);}})[_0x9a5c('0x2a')](function(_0x47a13a){logger['error'](_0x9a5c('0x21'),_0x5ef98e,_0x47a13a);_0x1e0c41(_0x47a13a);});});}function respondWithStatusCode(_0x263a19,_0x10db7a){_0x10db7a=_0x10db7a||0xcc;return function(_0x3713fd){if(_0x3713fd){return _0x263a19['sendStatus'](_0x10db7a);}return _0x263a19[_0x9a5c('0x2b')](_0x10db7a)[_0x9a5c('0x2c')]();};}function respondWithResult(_0x3b5d9c,_0x4119f7){_0x4119f7=_0x4119f7||0xc8;return function(_0x439e6b){if(_0x439e6b){return _0x3b5d9c[_0x9a5c('0x2b')](_0x4119f7)[_0x9a5c('0x2d')](_0x439e6b);}};}function respondWithFilteredResult(_0x4146c9,_0x3d3356){return function(_0x4e6cee){if(_0x4e6cee){var _0x2bdb5b=typeof _0x3d3356['offset']==='undefined'&&typeof _0x3d3356['limit']===_0x9a5c('0x2e');var _0x190943=_0x4e6cee[_0x9a5c('0x2f')];var _0xb966ad=_0x2bdb5b?0x0:_0x3d3356[_0x9a5c('0x30')];var _0x35d472=_0x2bdb5b?_0x4e6cee['count']:_0x3d3356[_0x9a5c('0x30')]+_0x3d3356[_0x9a5c('0x31')];var _0x39344c;if(_0x35d472>=_0x190943){_0x35d472=_0x190943;_0x39344c=0xc8;}else{_0x39344c=0xce;}_0x4146c9['status'](_0x39344c);return _0x4146c9[_0x9a5c('0x32')](_0x9a5c('0x33'),_0xb966ad+'-'+_0x35d472+'/'+_0x190943)[_0x9a5c('0x2d')](_0x4e6cee);}return null;};}function patchUpdates(_0x29bb2b){return function(_0x47db46){try{jsonpatch[_0x9a5c('0x34')](_0x47db46,_0x29bb2b,!![]);}catch(_0x582754){return BPromise[_0x9a5c('0x35')](_0x582754);}return _0x47db46['save']();};}function saveUpdates(_0x234c32,_0x14dd33){return function(_0x2c9f35){if(_0x2c9f35){return _0x2c9f35[_0x9a5c('0x36')](_0x234c32)[_0x9a5c('0x20')](function(_0x3792eb){return _0x3792eb;});}return null;};}function removeEntity(_0x5695a5,_0x472fa3){return function(_0x350bd4){if(_0x350bd4){return _0x350bd4[_0x9a5c('0x37')]()[_0x9a5c('0x20')](function(){_0x5695a5['status'](0xcc)[_0x9a5c('0x2c')]();});}};}function handleEntityNotFound(_0xe3feef,_0x5f545c){return function(_0x2329ba){if(!_0x2329ba){_0xe3feef[_0x9a5c('0x38')](0x194);}return _0x2329ba;};}function handleError(_0x574dd1,_0x37146a){_0x37146a=_0x37146a||0x1f4;return function(_0x510262){logger[_0x9a5c('0x25')](_0x510262[_0x9a5c('0x39')]);if(_0x510262[_0x9a5c('0x3a')]){delete _0x510262[_0x9a5c('0x3a')];}_0x574dd1[_0x9a5c('0x2b')](_0x37146a)['send'](_0x510262);};}exports['index']=function(_0x5c4b29,_0x5e8935){var _0x350026={},_0x3523eb={},_0x28cfd2={'count':0x0,'rows':[]};var _0x2918d9=_[_0x9a5c('0x3b')](db[_0x9a5c('0x3c')][_0x9a5c('0x3d')],function(_0x24879e){return{'name':_0x24879e[_0x9a5c('0x3e')],'type':_0x24879e[_0x9a5c('0x3f')][_0x9a5c('0x40')]};});_0x3523eb['model']=_[_0x9a5c('0x3b')](_0x2918d9,_0x9a5c('0x3a'));_0x3523eb[_0x9a5c('0x41')]=_[_0x9a5c('0x42')](_0x5c4b29['query']);_0x3523eb[_0x9a5c('0x43')]=_[_0x9a5c('0x44')](_0x3523eb['model'],_0x3523eb[_0x9a5c('0x41')]);_0x350026[_0x9a5c('0x45')]=_[_0x9a5c('0x44')](_0x3523eb[_0x9a5c('0x46')],qs[_0x9a5c('0x47')](_0x5c4b29[_0x9a5c('0x41')][_0x9a5c('0x47')]));_0x350026[_0x9a5c('0x45')]=_0x350026[_0x9a5c('0x45')][_0x9a5c('0x48')]?_0x350026['attributes']:_0x3523eb['model'];if(!_0x5c4b29[_0x9a5c('0x41')][_0x9a5c('0x49')](_0x9a5c('0x4a'))){_0x350026[_0x9a5c('0x31')]=qs[_0x9a5c('0x31')](_0x5c4b29[_0x9a5c('0x41')][_0x9a5c('0x31')]);_0x350026[_0x9a5c('0x30')]=qs[_0x9a5c('0x30')](_0x5c4b29[_0x9a5c('0x41')][_0x9a5c('0x30')]);}_0x350026[_0x9a5c('0x4b')]=qs['sort'](_0x5c4b29['query'][_0x9a5c('0x4c')]);_0x350026[_0x9a5c('0x4d')]=qs['filters'](_[_0x9a5c('0x4e')](_0x5c4b29[_0x9a5c('0x41')],_0x3523eb['filters']),_0x2918d9);if(_0x5c4b29['query']['filter']){_0x350026[_0x9a5c('0x4d')]=_['merge'](_0x350026[_0x9a5c('0x4d')],{'$or':_[_0x9a5c('0x3b')](_0x2918d9,function(_0x57864e){if(_0x57864e[_0x9a5c('0x3f')]!==_0x9a5c('0x4f')){var _0x56ede0={};_0x56ede0[_0x57864e[_0x9a5c('0x3a')]]={'$like':'%'+_0x5c4b29[_0x9a5c('0x41')]['filter']+'%'};return _0x56ede0;}})});}_0x350026=_['merge']({},_0x350026,_0x5c4b29[_0x9a5c('0x50')]);var _0x27f89f={'where':_0x350026[_0x9a5c('0x4d')]};return db['SmsMessage'][_0x9a5c('0x2f')](_0x27f89f)[_0x9a5c('0x20')](function(_0x2733db){_0x28cfd2[_0x9a5c('0x2f')]=_0x2733db;if(_0x5c4b29['query'][_0x9a5c('0x51')]){_0x350026[_0x9a5c('0x52')]=[{'all':!![]}];}return db['SmsMessage'][_0x9a5c('0x53')](_0x350026);})[_0x9a5c('0x20')](function(_0x2831dc){_0x28cfd2[_0x9a5c('0x54')]=_0x2831dc;return _0x28cfd2;})[_0x9a5c('0x20')](respondWithFilteredResult(_0x5e8935,_0x350026))[_0x9a5c('0x2a')](handleError(_0x5e8935,null));};exports[_0x9a5c('0x55')]=function(_0x5e0297,_0x2782c4){var _0x57f53a={'raw':!![],'where':{'id':_0x5e0297['params']['id']}},_0x199ee1={};_0x199ee1[_0x9a5c('0x46')]=_[_0x9a5c('0x42')](db['SmsMessage'][_0x9a5c('0x3d')]);_0x199ee1['query']=_['keys'](_0x5e0297[_0x9a5c('0x41')]);_0x199ee1[_0x9a5c('0x43')]=_[_0x9a5c('0x44')](_0x199ee1['model'],_0x199ee1[_0x9a5c('0x41')]);_0x57f53a[_0x9a5c('0x45')]=_[_0x9a5c('0x44')](_0x199ee1[_0x9a5c('0x46')],qs[_0x9a5c('0x47')](_0x5e0297[_0x9a5c('0x41')][_0x9a5c('0x47')]));_0x57f53a[_0x9a5c('0x45')]=_0x57f53a[_0x9a5c('0x45')][_0x9a5c('0x48')]?_0x57f53a['attributes']:_0x199ee1['model'];if(_0x5e0297[_0x9a5c('0x41')][_0x9a5c('0x51')]){_0x57f53a[_0x9a5c('0x52')]=[{'all':!![]}];}_0x57f53a=_[_0x9a5c('0x56')]({},_0x57f53a,_0x5e0297['options']);return db['SmsMessage'][_0x9a5c('0x57')](_0x57f53a)[_0x9a5c('0x20')](handleEntityNotFound(_0x2782c4,null))[_0x9a5c('0x20')](respondWithResult(_0x2782c4,null))[_0x9a5c('0x2a')](handleError(_0x2782c4,null));};exports['create']=function(_0x35ba8c,_0x22f70b){return db['SmsMessage'][_0x9a5c('0x58')](_0x35ba8c[_0x9a5c('0x59')],{})[_0x9a5c('0x20')](respondWithResult(_0x22f70b,0xc9))[_0x9a5c('0x2a')](handleError(_0x22f70b,null));};exports['update']=function(_0x539c49,_0x5176c3){if(_0x539c49[_0x9a5c('0x59')]['id']){delete _0x539c49[_0x9a5c('0x59')]['id'];}return db['SmsMessage'][_0x9a5c('0x57')]({'where':{'id':_0x539c49[_0x9a5c('0x5a')]['id']}})[_0x9a5c('0x20')](handleEntityNotFound(_0x5176c3,null))['then'](saveUpdates(_0x539c49[_0x9a5c('0x59')],null))[_0x9a5c('0x20')](respondWithResult(_0x5176c3,null))[_0x9a5c('0x2a')](handleError(_0x5176c3,null));};exports[_0x9a5c('0x37')]=function(_0x530706,_0x1f9873){return db['SmsMessage'][_0x9a5c('0x57')]({'where':{'id':_0x530706[_0x9a5c('0x5a')]['id']}})[_0x9a5c('0x20')](handleEntityNotFound(_0x1f9873,null))[_0x9a5c('0x20')](removeEntity(_0x1f9873,null))[_0x9a5c('0x2a')](handleError(_0x1f9873,null));};exports[_0x9a5c('0x5b')]=function(_0x54e7ec,_0x757886){return db[_0x9a5c('0x3c')][_0x9a5c('0x5b')]()[_0x9a5c('0x20')](respondWithResult(_0x757886,null))['catch'](handleError(_0x757886,null));};var interaction_log=require(_0x9a5c('0x10'))(_0x9a5c('0x5c'));exports[_0x9a5c('0x5d')]=function(_0x1dce3a,_0x2ff03f,_0x5d9cd2){var _0x80e8c4={'agent':{},'channel':_0x9a5c('0x5e')};if(_0x1dce3a[_0x9a5c('0x59')]['id']){delete _0x1dce3a[_0x9a5c('0x59')]['id'];}_0x1dce3a[_0x9a5c('0x59')][_0x9a5c('0x5f')]=!![];_0x1dce3a[_0x9a5c('0x59')][_0x9a5c('0x60')]=moment()['format'](_0x9a5c('0x61'));_0x1dce3a[_0x9a5c('0x59')]['UserId']=_0x1dce3a[_0x9a5c('0x59')]['UserId']||_0x1dce3a[_0x9a5c('0x62')]['id'];_0x80e8c4['agent']['id']=_0x1dce3a[_0x9a5c('0x59')][_0x9a5c('0x63')];return db['SmsMessage'][_0x9a5c('0x57')]({'where':{'id':_0x1dce3a[_0x9a5c('0x5a')]['id'],'UserId':null}})[_0x9a5c('0x20')](handleEntityNotFound(_0x2ff03f,null))[_0x9a5c('0x20')](saveUpdates(_0x1dce3a[_0x9a5c('0x59')],null))[_0x9a5c('0x20')](function(_0xfca83b){if(_0xfca83b){_0x80e8c4[_0x9a5c('0x27')]=_0xfca83b[_0x9a5c('0x64')]({'plain':!![]});return db[_0x9a5c('0x65')][_0x9a5c('0x57')]({'where':{'id':_0xfca83b[_0x9a5c('0x66')]}});}return null;})['then'](handleEntityNotFound(_0x2ff03f,null))[_0x9a5c('0x20')](function(_0x476ec2){if(_0x476ec2){return _0x476ec2[_0x9a5c('0x36')]({'UserId':_0x1dce3a[_0x9a5c('0x59')][_0x9a5c('0x63')],'read1stAt':_[_0x9a5c('0x67')](_0x476ec2[_0x9a5c('0x68')])?moment()[_0x9a5c('0x69')](_0x9a5c('0x61')):undefined});}return null;})[_0x9a5c('0x20')](function(_0x2d4d5c){if(_0x2d4d5c){_0x80e8c4[_0x9a5c('0x6a')]=_0x2d4d5c['get']({'plain':!![]});interaction_log[_0x9a5c('0x28')](_0x9a5c('0x6b'),_0x1dce3a['user']['id'],_0x1dce3a[_0x9a5c('0x62')]['name'],_0x1dce3a[_0x9a5c('0x62')][_0x9a5c('0x6c')],_0x80e8c4[_0x9a5c('0x6a')]['id'],_0x1dce3a[_0x9a5c('0x59')]?JSON[_0x9a5c('0x24')](_0x1dce3a['body']):_0x9a5c('0x6d'));return respondWithRpcPromise(_0x9a5c('0x6e'),_0x9a5c('0x6f'),_0x80e8c4);}return null;})[_0x9a5c('0x20')](function(_0x299c01){var _0x35892a='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x299c01[_0x9a5c('0x27')][_0x9a5c('0x70')];return db[_0x9a5c('0x71')]['query'](_0x35892a,{'type':db[_0x9a5c('0x72')]['QueryTypes'][_0x9a5c('0x73')],'raw':!![]})['then'](function(_0x6d5edd){return _0x6d5edd;});})['then'](function(_0x423b93){if(_0x423b93){_0x80e8c4[_0x9a5c('0x27')]['contact']=_0x423b93[0x0];if(!_0x1dce3a[_0x9a5c('0x59')][_0x9a5c('0x63')])return;return db['User'][_0x9a5c('0x57')]({'where':{'id':_0x1dce3a[_0x9a5c('0x59')]['UserId'],'role':_0x9a5c('0x74')},'attributes':['id',_0x9a5c('0x3a'),_0x9a5c('0x75'),_0x9a5c('0x76'),_0x9a5c('0x77')],'raw':!![]});}return null;})[_0x9a5c('0x20')](function(_0x35f68c){if(!_0x35f68c)return null;_0x80e8c4[_0x9a5c('0x27')][_0x9a5c('0x74')]=_0x35f68c;return _0x80e8c4;})[_0x9a5c('0x20')](function(_0x25331f){if(_0x25331f){if(_0x1dce3a[_0x9a5c('0x59')]['manual']){_0x80e8c4[_0x9a5c('0x27')][_0x9a5c('0x78')]=util[_0x9a5c('0x69')](_0x9a5c('0x79'),_0x1dce3a[_0x9a5c('0x62')][_0x9a5c('0x3a')]);_0x80e8c4[_0x9a5c('0x27')][_0x9a5c('0x7a')]=_0x80e8c4[_0x9a5c('0x7a')];_0x80e8c4['message']['motionChannel']=_0x80e8c4[_0x9a5c('0x7a')];_0x80e8c4['message']['event']=_0x9a5c('0x5d');return respondWithRpcPromise(_0x9a5c('0x7b'),_0x9a5c('0x7b'),{'event':_0x9a5c('0x7c'),'message':_0x80e8c4[_0x9a5c('0x27')]},client9002)[_0x9a5c('0x20')](function(){return _0x80e8c4;});}return _0x80e8c4;}return null;})[_0x9a5c('0x20')](respondWithResult(_0x2ff03f,null))[_0x9a5c('0x2a')](handleError(_0x2ff03f,null));};var interaction_log=require(_0x9a5c('0x10'))(_0x9a5c('0x5c'));exports['reject']=function(_0x5dac8d,_0x1fb3ff,_0x10dfa3){var _0x289e2c={'agent':{},'channel':'sms'};if(_0x5dac8d[_0x9a5c('0x59')]['id']){delete _0x5dac8d[_0x9a5c('0x59')]['id'];}_0x5dac8d['body'][_0x9a5c('0x63')]=_0x5dac8d['body'][_0x9a5c('0x63')]||_0x5dac8d[_0x9a5c('0x62')]['id'];_0x289e2c['agent']['id']=_0x5dac8d[_0x9a5c('0x59')][_0x9a5c('0x63')];return db[_0x9a5c('0x3c')][_0x9a5c('0x57')]({'where':{'id':_0x5dac8d['params']['id'],'UserId':null}})[_0x9a5c('0x20')](handleEntityNotFound(_0x1fb3ff,null))[_0x9a5c('0x20')](function(_0x46e438){if(_0x46e438){_0x289e2c['message']=_0x46e438['get']({'plain':!![]});return db[_0x9a5c('0x65')]['find']({'where':{'id':_0x46e438['SmsInteractionId']}});}return null;})['then'](handleEntityNotFound(_0x1fb3ff,null))[_0x9a5c('0x20')](function(_0x293c43){if(_0x293c43){_0x289e2c[_0x9a5c('0x6a')]=_0x293c43[_0x9a5c('0x64')]({'plain':!![]});interaction_log[_0x9a5c('0x28')](_0x9a5c('0x7d'),_0x5dac8d[_0x9a5c('0x62')]['id'],_0x5dac8d[_0x9a5c('0x62')][_0x9a5c('0x3a')],_0x5dac8d[_0x9a5c('0x62')]['role'],_0x289e2c[_0x9a5c('0x6a')]['id'],_0x5dac8d[_0x9a5c('0x59')]?JSON[_0x9a5c('0x24')](_0x5dac8d['body']):'null');return respondWithRpcPromise(_0x9a5c('0x7e'),_0x9a5c('0x7f'),_0x289e2c);}return null;})[_0x9a5c('0x20')](function(_0x3eaa00){var _0x40c136=_0x9a5c('0x80')+_0x3eaa00[_0x9a5c('0x27')][_0x9a5c('0x70')];return db[_0x9a5c('0x71')]['query'](_0x40c136,{'type':db[_0x9a5c('0x72')][_0x9a5c('0x81')]['SELECT'],'raw':!![]})[_0x9a5c('0x20')](function(_0x2c2535){return _0x2c2535;});})[_0x9a5c('0x20')](function(_0x56b3e5){if(_0x56b3e5){_0x289e2c['message'][_0x9a5c('0x82')]=_0x56b3e5[0x0];if(!_0x5dac8d['body'][_0x9a5c('0x63')])return;return db[_0x9a5c('0x83')]['find']({'where':{'id':_0x5dac8d[_0x9a5c('0x59')][_0x9a5c('0x63')],'role':_0x9a5c('0x74')},'attributes':['id',_0x9a5c('0x3a'),_0x9a5c('0x75'),_0x9a5c('0x76'),'internal'],'raw':!![]});}return null;})['then'](function(_0x433f8a){if(!_0x433f8a)return null;_0x289e2c[_0x9a5c('0x27')]['agent']=_0x433f8a;return _0x289e2c;})[_0x9a5c('0x20')](function(_0x2ff2d0){if(_0x2ff2d0){_0x2ff2d0[_0x9a5c('0x27')][_0x9a5c('0x78')]=util[_0x9a5c('0x69')](_0x9a5c('0x79'),_0x5dac8d['user']['name']);_0x2ff2d0['message'][_0x9a5c('0x7a')]=_0x289e2c['channel'];_0x2ff2d0[_0x9a5c('0x27')][_0x9a5c('0x84')]=_0x289e2c[_0x9a5c('0x7a')];_0x2ff2d0[_0x9a5c('0x27')][_0x9a5c('0x85')]=_0x9a5c('0x35');respondWithRpcPromise(_0x9a5c('0x7b'),_0x9a5c('0x7b'),{'event':_0x9a5c('0x86'),'message':_0x2ff2d0[_0x9a5c('0x27')]},client9002);return _0x289e2c;}return null;})[_0x9a5c('0x20')](respondWithResult(_0x1fb3ff,null))[_0x9a5c('0x2a')](handleError(_0x1fb3ff,null));};exports[_0x9a5c('0x2b')]=function(_0x5a9cc3,_0x1776b3,_0x5909af){if(_0x5a9cc3[_0x9a5c('0x59')]['id']){delete _0x5a9cc3['body']['id'];}var _0x4ed020;return db[_0x9a5c('0x3c')][_0x9a5c('0x57')]({'where':{'id':_0x5a9cc3[_0x9a5c('0x5a')]['id']}})[_0x9a5c('0x20')](handleEntityNotFound(_0x1776b3,null))[_0x9a5c('0x20')](function(_0x46848a){if(_0x46848a){_0x4ed020=_0x46848a;return db[_0x9a5c('0x87')][_0x9a5c('0x57')]({'where':{'id':_0x46848a[_0x9a5c('0x88')]}});}})[_0x9a5c('0x20')](handleEntityNotFound(_0x1776b3,null))[_0x9a5c('0x20')](function(_0x5b260c){if(_0x5b260c){logger[_0x9a5c('0x23')]('SmsMessage,\x20%s,\x20%s,\x20%s','status',_0x9a5c('0x89'),_0x5b260c[_0x9a5c('0x3f')],util[_0x9a5c('0x8a')](_0x5a9cc3[_0x9a5c('0x59')],{'showHidden':![],'depth':null}));switch(_0x5b260c['type']){case _0x9a5c('0x8b'):if(_0x5a9cc3[_0x9a5c('0x59')][_0x9a5c('0x8c')]&&_0x5a9cc3[_0x9a5c('0x59')]['MessageSid']===_0x4ed020[_0x9a5c('0x8d')]){return _0x4ed020[_0x9a5c('0x36')]({'read':!![]});}else{logger[_0x9a5c('0x25')](_0x9a5c('0x8e'),_0x9a5c('0x2b'),_0x9a5c('0x8b'),util['inspect'](_0x5a9cc3[_0x9a5c('0x59')],{'showHidden':![],'depth':null}));}break;case _0x9a5c('0x8f'):if(_0x5a9cc3[_0x9a5c('0x59')][_0x9a5c('0x90')]&&_0x5a9cc3[_0x9a5c('0x59')][_0x9a5c('0x90')]===_0x4ed020[_0x9a5c('0x8d')]&&_[_0x9a5c('0x91')]([_0x9a5c('0x92'),'delivered'],_0x5a9cc3[_0x9a5c('0x59')][_0x9a5c('0x93')])>=0x0){return _0x4ed020[_0x9a5c('0x36')]({'read':!![]});}else{logger[_0x9a5c('0x25')](_0x9a5c('0x8e'),'status','plivio',util[_0x9a5c('0x8a')](_0x5a9cc3[_0x9a5c('0x59')],{'showHidden':![],'depth':null}));}break;case'infobip':var _0x4235d4=_0x5a9cc3[_0x9a5c('0x59')][_0x9a5c('0x94')][0x0];if(_0x4235d4[_0x9a5c('0x2b')]['groupName']===_0x9a5c('0x95')){return _0x4ed020[_0x9a5c('0x36')]({'read':!![]});}else{logger['error'](_0x9a5c('0x8e'),_0x9a5c('0x2b'),_0x9a5c('0x96'),util['inspect'](_0x5a9cc3[_0x9a5c('0x59')],{'showHidden':![],'depth':null}));}break;}return _0x4ed020;}})[_0x9a5c('0x20')](respondWithResult(_0x1776b3,null))[_0x9a5c('0x2a')](handleError(_0x1776b3,null));};
\ No newline at end of file