Built motion from commit fe909640.|2.6.8
[motion2.git] / server / api / smsMessage / smsMessage.controller.js
index 3026a0d..fc46c81 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3aaf=['sms-interactions','accept','sms','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','CmContact','Contact','get','SmsInteraction','SmsInteractionId','info','[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','stringify','null','AcceptMessage','acceptMessage','manual','interface','SIP/%s','channel','event','EventManager','acceptmessage','interaction','[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','RejectMessage','rejectMessage','SmsAccount','SmsAccountId','debug','SmsMessage,\x20%s,\x20%s,\x20%s','inspect','twilio','MessageSid','plivo','MessageUUID','messageId','indexOf','sent','SmsAccount,\x20%s,\x20%s,\x20%s','plivio','results','groupName','DELIVERED','infobip','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','./smsMessage.socket','register','jayson/promise','client','http','SmsMessage,\x20%s,\x20%s','request\x20sent','error','code','message','result','sendStatus','status','json','count','offset','set','Content-Range','apply','reject','update','destroy','then','end','stack','name','send','index','map','SmsMessage','rawAttributes','fieldName','type','key','model','query','filters','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','keys','intersection','find','create','body','describe'];(function(_0x1059cc,_0x5ce414){var _0x28dd79=function(_0x2dbd80){while(--_0x2dbd80){_0x1059cc['push'](_0x1059cc['shift']());}};_0x28dd79(++_0x5ce414);}(_0x3aaf,0xbf));var _0xf3aa=function(_0x2b10c6,_0x185590){_0x2b10c6=_0x2b10c6-0x0;var _0x3789d2=_0x3aaf[_0x2b10c6];return _0x3789d2;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xf3aa('0x0'));var rimraf=require(_0xf3aa('0x1'));var zipdir=require(_0xf3aa('0x2'));var jsonpatch=require(_0xf3aa('0x3'));var rp=require(_0xf3aa('0x4'));var moment=require(_0xf3aa('0x5'));var BPromise=require(_0xf3aa('0x6'));var Mustache=require(_0xf3aa('0x7'));var util=require(_0xf3aa('0x8'));var path=require(_0xf3aa('0x9'));var sox=require(_0xf3aa('0xa'));var csv=require(_0xf3aa('0xb'));var ejs=require(_0xf3aa('0xc'));var fs=require('fs');var _=require(_0xf3aa('0xd'));var squel=require(_0xf3aa('0xe'));var crypto=require('crypto');var jsforce=require(_0xf3aa('0xf'));var deskjs=require(_0xf3aa('0x10'));var toCsv=require(_0xf3aa('0xb'));var querystring=require('querystring');var Papa=require(_0xf3aa('0x11'));var Redis=require(_0xf3aa('0x12'));var authService=require(_0xf3aa('0x13'));var qs=require(_0xf3aa('0x14'));var as=require(_0xf3aa('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf3aa('0x16'))(_0xf3aa('0x17'));var utils=require('../../config/utils');var config=require(_0xf3aa('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xf3aa('0x19'))['db'];config[_0xf3aa('0x1a')]=_[_0xf3aa('0x1b')](config[_0xf3aa('0x1a')],{'host':_0xf3aa('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf3aa('0x1a')]));require(_0xf3aa('0x1d'))[_0xf3aa('0x1e')](socket);var jayson=require(_0xf3aa('0x1f'));var client=jayson[_0xf3aa('0x20')][_0xf3aa('0x21')]({'port':0x232c});var client9002=jayson[_0xf3aa('0x20')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2e06c7,_0x2da228,_0x269b0a,_0x1fff21){return new BPromise(function(_0x59dda4,_0x4c77fb){var _0x1584d3=_0x1fff21||client;return _0x1584d3['request'](_0x2e06c7,_0x269b0a)['then'](function(_0x1afa0c){logger['info'](_0xf3aa('0x22'),_0x2da228,'request\x20sent');logger['debug']('SmsMessage,\x20%s,\x20%s,\x20%s',_0x2da228,_0xf3aa('0x23'),JSON['stringify'](_0x1afa0c));if(_0x1afa0c[_0xf3aa('0x24')]){if(_0x1afa0c[_0xf3aa('0x24')][_0xf3aa('0x25')]===0x1f4){logger[_0xf3aa('0x24')]('SmsMessage,\x20%s,\x20%s',_0x2da228,_0x1afa0c[_0xf3aa('0x24')][_0xf3aa('0x26')]);return _0x4c77fb(_0x1afa0c[_0xf3aa('0x24')]['message']);}logger[_0xf3aa('0x24')]('SmsMessage,\x20%s,\x20%s',_0x2da228,_0x1afa0c[_0xf3aa('0x24')][_0xf3aa('0x26')]);return _0x59dda4(_0x1afa0c[_0xf3aa('0x24')][_0xf3aa('0x26')]);}else{logger['info'](_0xf3aa('0x22'),_0x2da228,'request\x20sent');_0x59dda4(_0x1afa0c[_0xf3aa('0x27')][_0xf3aa('0x26')]);}})['catch'](function(_0x690f17){logger['error'](_0xf3aa('0x22'),_0x2da228,_0x690f17);_0x4c77fb(_0x690f17);});});}function respondWithStatusCode(_0x3f25c8,_0x58c802){_0x58c802=_0x58c802||0xcc;return function(_0x5759d0){if(_0x5759d0){return _0x3f25c8[_0xf3aa('0x28')](_0x58c802);}return _0x3f25c8['status'](_0x58c802)['end']();};}function respondWithResult(_0x5b4a88,_0x102ec1){_0x102ec1=_0x102ec1||0xc8;return function(_0x2fd18b){if(_0x2fd18b){return _0x5b4a88[_0xf3aa('0x29')](_0x102ec1)[_0xf3aa('0x2a')](_0x2fd18b);}};}function respondWithFilteredResult(_0x327c2b,_0x66bb55){return function(_0x37c9cd){if(_0x37c9cd){var _0x1a1452=_0x37c9cd[_0xf3aa('0x2b')],_0x1108c7=_0x66bb55['offset'],_0x19f763=_0x66bb55[_0xf3aa('0x2c')]+_0x66bb55['limit'],_0x2cb0fa;if(_0x19f763>=_0x1a1452){_0x19f763=_0x1a1452;_0x2cb0fa=0xc8;}else{_0x2cb0fa=0xce;}_0x327c2b[_0xf3aa('0x29')](_0x2cb0fa);return _0x327c2b[_0xf3aa('0x2d')](_0xf3aa('0x2e'),_0x1108c7+'-'+_0x19f763+'/'+_0x1a1452)[_0xf3aa('0x2a')](_0x37c9cd);}return null;};}function patchUpdates(_0x3765d5){return function(_0x2c105a){try{jsonpatch[_0xf3aa('0x2f')](_0x2c105a,_0x3765d5,!![]);}catch(_0x4a5c27){return BPromise[_0xf3aa('0x30')](_0x4a5c27);}return _0x2c105a['save']();};}function saveUpdates(_0x5df852,_0x512092){return function(_0x4989d3){if(_0x4989d3){return _0x4989d3[_0xf3aa('0x31')](_0x5df852)['then'](function(_0x29c8e1){return _0x29c8e1;});}return null;};}function removeEntity(_0x278ea9,_0x308d9b){return function(_0x32a4af){if(_0x32a4af){return _0x32a4af[_0xf3aa('0x32')]()[_0xf3aa('0x33')](function(){_0x278ea9[_0xf3aa('0x29')](0xcc)[_0xf3aa('0x34')]();});}};}function handleEntityNotFound(_0x1c4b44,_0x1c3de1){return function(_0x149211){if(!_0x149211){_0x1c4b44['sendStatus'](0x194);}return _0x149211;};}function handleError(_0x3f5d7a,_0x9da67d){_0x9da67d=_0x9da67d||0x1f4;return function(_0x5a1044){logger[_0xf3aa('0x24')](_0x5a1044[_0xf3aa('0x35')]);if(_0x5a1044[_0xf3aa('0x36')]){delete _0x5a1044[_0xf3aa('0x36')];}_0x3f5d7a['status'](_0x9da67d)[_0xf3aa('0x37')](_0x5a1044);};}exports[_0xf3aa('0x38')]=function(_0x4f97f6,_0x1b19de){var _0x1f3ba2={},_0x2f27c3={},_0x488d86={'count':0x0,'rows':[]};var _0x1ec49f=_[_0xf3aa('0x39')](db[_0xf3aa('0x3a')][_0xf3aa('0x3b')],function(_0x48943d){return{'name':_0x48943d[_0xf3aa('0x3c')],'type':_0x48943d[_0xf3aa('0x3d')][_0xf3aa('0x3e')]};});_0x2f27c3[_0xf3aa('0x3f')]=_[_0xf3aa('0x39')](_0x1ec49f,'name');_0x2f27c3[_0xf3aa('0x40')]=_['keys'](_0x4f97f6[_0xf3aa('0x40')]);_0x2f27c3[_0xf3aa('0x41')]=_['intersection'](_0x2f27c3[_0xf3aa('0x3f')],_0x2f27c3['query']);_0x1f3ba2[_0xf3aa('0x42')]=_['intersection'](_0x2f27c3['model'],qs[_0xf3aa('0x43')](_0x4f97f6[_0xf3aa('0x40')]['fields']));_0x1f3ba2[_0xf3aa('0x42')]=_0x1f3ba2[_0xf3aa('0x42')][_0xf3aa('0x44')]?_0x1f3ba2['attributes']:_0x2f27c3[_0xf3aa('0x3f')];if(!_0x4f97f6['query'][_0xf3aa('0x45')](_0xf3aa('0x46'))){_0x1f3ba2['limit']=qs['limit'](_0x4f97f6['query'][_0xf3aa('0x47')]);_0x1f3ba2[_0xf3aa('0x2c')]=qs[_0xf3aa('0x2c')](_0x4f97f6['query'][_0xf3aa('0x2c')]);}_0x1f3ba2[_0xf3aa('0x48')]=qs[_0xf3aa('0x49')](_0x4f97f6[_0xf3aa('0x40')][_0xf3aa('0x49')]);_0x1f3ba2[_0xf3aa('0x4a')]=qs['filters'](_[_0xf3aa('0x4b')](_0x4f97f6[_0xf3aa('0x40')],_0x2f27c3['filters']),_0x1ec49f);if(_0x4f97f6[_0xf3aa('0x40')][_0xf3aa('0x4c')]){_0x1f3ba2['where']=_[_0xf3aa('0x4d')](_0x1f3ba2[_0xf3aa('0x4a')],{'$or':_[_0xf3aa('0x39')](_0x1ec49f,function(_0x559d2d){if(_0x559d2d['type']!==_0xf3aa('0x4e')){var _0x1762af={};_0x1762af[_0x559d2d[_0xf3aa('0x36')]]={'$like':'%'+_0x4f97f6['query'][_0xf3aa('0x4c')]+'%'};return _0x1762af;}})});}_0x1f3ba2=_['merge']({},_0x1f3ba2,_0x4f97f6[_0xf3aa('0x4f')]);var _0x56a6a9={'where':_0x1f3ba2['where']};return db[_0xf3aa('0x3a')]['count'](_0x56a6a9)[_0xf3aa('0x33')](function(_0x3fa2f4){_0x488d86[_0xf3aa('0x2b')]=_0x3fa2f4;if(_0x4f97f6[_0xf3aa('0x40')][_0xf3aa('0x50')]){_0x1f3ba2[_0xf3aa('0x51')]=[{'all':!![]}];}return db[_0xf3aa('0x3a')][_0xf3aa('0x52')](_0x1f3ba2);})[_0xf3aa('0x33')](function(_0x274df5){_0x488d86[_0xf3aa('0x53')]=_0x274df5;return _0x488d86;})[_0xf3aa('0x33')](respondWithFilteredResult(_0x1b19de,_0x1f3ba2))[_0xf3aa('0x54')](handleError(_0x1b19de,null));};exports[_0xf3aa('0x55')]=function(_0x11c516,_0x441e27){var _0x5108af={'raw':!![],'where':{'id':_0x11c516[_0xf3aa('0x56')]['id']}},_0x3fa930={};_0x3fa930['model']=_[_0xf3aa('0x57')](db[_0xf3aa('0x3a')][_0xf3aa('0x3b')]);_0x3fa930['query']=_[_0xf3aa('0x57')](_0x11c516[_0xf3aa('0x40')]);_0x3fa930[_0xf3aa('0x41')]=_[_0xf3aa('0x58')](_0x3fa930[_0xf3aa('0x3f')],_0x3fa930[_0xf3aa('0x40')]);_0x5108af['attributes']=_['intersection'](_0x3fa930['model'],qs['fields'](_0x11c516['query']['fields']));_0x5108af[_0xf3aa('0x42')]=_0x5108af[_0xf3aa('0x42')][_0xf3aa('0x44')]?_0x5108af[_0xf3aa('0x42')]:_0x3fa930[_0xf3aa('0x3f')];if(_0x11c516[_0xf3aa('0x40')]['includeAll']){_0x5108af['include']=[{'all':!![]}];}_0x5108af=_[_0xf3aa('0x4d')]({},_0x5108af,_0x11c516[_0xf3aa('0x4f')]);return db[_0xf3aa('0x3a')][_0xf3aa('0x59')](_0x5108af)[_0xf3aa('0x33')](handleEntityNotFound(_0x441e27,null))[_0xf3aa('0x33')](respondWithResult(_0x441e27,null))[_0xf3aa('0x54')](handleError(_0x441e27,null));};exports[_0xf3aa('0x5a')]=function(_0x4d9c84,_0x18c838){return db[_0xf3aa('0x3a')][_0xf3aa('0x5a')](_0x4d9c84[_0xf3aa('0x5b')],{})[_0xf3aa('0x33')](respondWithResult(_0x18c838,0xc9))[_0xf3aa('0x54')](handleError(_0x18c838,null));};exports[_0xf3aa('0x31')]=function(_0x29aaac,_0x2c17f3){if(_0x29aaac[_0xf3aa('0x5b')]['id']){delete _0x29aaac[_0xf3aa('0x5b')]['id'];}return db[_0xf3aa('0x3a')][_0xf3aa('0x59')]({'where':{'id':_0x29aaac[_0xf3aa('0x56')]['id']}})[_0xf3aa('0x33')](handleEntityNotFound(_0x2c17f3,null))[_0xf3aa('0x33')](saveUpdates(_0x29aaac[_0xf3aa('0x5b')],null))[_0xf3aa('0x33')](respondWithResult(_0x2c17f3,null))[_0xf3aa('0x54')](handleError(_0x2c17f3,null));};exports[_0xf3aa('0x32')]=function(_0x5a9958,_0xcf9a99){return db[_0xf3aa('0x3a')][_0xf3aa('0x59')]({'where':{'id':_0x5a9958[_0xf3aa('0x56')]['id']}})[_0xf3aa('0x33')](handleEntityNotFound(_0xcf9a99,null))[_0xf3aa('0x33')](removeEntity(_0xcf9a99,null))[_0xf3aa('0x54')](handleError(_0xcf9a99,null));};exports['describe']=function(_0x403e56,_0xcbbf2f){return db[_0xf3aa('0x3a')][_0xf3aa('0x5c')]()[_0xf3aa('0x33')](respondWithResult(_0xcbbf2f,null))['catch'](handleError(_0xcbbf2f,null));};var interaction_log=require(_0xf3aa('0x16'))(_0xf3aa('0x5d'));exports[_0xf3aa('0x5e')]=function(_0x1c27c8,_0xaad47f,_0x261c6b){var _0x6edccf={'agent':{},'channel':_0xf3aa('0x5f')};if(_0x1c27c8[_0xf3aa('0x5b')]['id']){delete _0x1c27c8[_0xf3aa('0x5b')]['id'];}_0x1c27c8[_0xf3aa('0x5b')]['read']=!![];_0x1c27c8[_0xf3aa('0x5b')]['readAt']=moment()[_0xf3aa('0x60')](_0xf3aa('0x61'));_0x1c27c8[_0xf3aa('0x5b')][_0xf3aa('0x62')]=_0x1c27c8[_0xf3aa('0x5b')]['UserId']||_0x1c27c8[_0xf3aa('0x63')]['id'];_0x6edccf[_0xf3aa('0x64')]['id']=_0x1c27c8[_0xf3aa('0x5b')][_0xf3aa('0x62')];return db[_0xf3aa('0x3a')]['find']({'where':{'id':_0x1c27c8[_0xf3aa('0x56')]['id'],'UserId':null},'include':[{'model':db[_0xf3aa('0x65')],'as':_0xf3aa('0x66')}]})[_0xf3aa('0x33')](handleEntityNotFound(_0xaad47f,null))[_0xf3aa('0x33')](saveUpdates(_0x1c27c8[_0xf3aa('0x5b')],null))[_0xf3aa('0x33')](function(_0x337b0b){if(_0x337b0b){_0x6edccf['message']=_0x337b0b[_0xf3aa('0x67')]({'plain':!![]});return db[_0xf3aa('0x68')][_0xf3aa('0x59')]({'where':{'id':_0x337b0b[_0xf3aa('0x69')]}});}return null;})[_0xf3aa('0x33')](handleEntityNotFound(_0xaad47f,null))['then'](function(_0x1959be){if(_0x1959be){return _0x1959be[_0xf3aa('0x31')]({'UserId':_0x1c27c8['body'][_0xf3aa('0x62')],'read1stAt':_['isNil'](_0x1959be['read1stAt'])?moment()[_0xf3aa('0x60')](_0xf3aa('0x61')):undefined});}return null;})[_0xf3aa('0x33')](function(_0x447c7d){if(_0x447c7d){_0x6edccf['interaction']=_0x447c7d[_0xf3aa('0x67')]({'plain':!![]});interaction_log[_0xf3aa('0x6a')](_0xf3aa('0x6b'),_0x1c27c8[_0xf3aa('0x63')]['id'],_0x1c27c8[_0xf3aa('0x63')]['name'],_0x1c27c8[_0xf3aa('0x63')]['role'],_0x6edccf['interaction']['id'],_0x1c27c8[_0xf3aa('0x5b')]?JSON[_0xf3aa('0x6c')](_0x1c27c8[_0xf3aa('0x5b')]):_0xf3aa('0x6d'));return respondWithRpcPromise(_0xf3aa('0x6e'),_0xf3aa('0x6f'),_0x6edccf);}return null;})[_0xf3aa('0x33')](function(_0x2c607c){if(_0x2c607c){if(_0x1c27c8[_0xf3aa('0x5b')][_0xf3aa('0x70')]){_0x6edccf[_0xf3aa('0x26')][_0xf3aa('0x71')]=util[_0xf3aa('0x60')](_0xf3aa('0x72'),_0x1c27c8[_0xf3aa('0x63')][_0xf3aa('0x36')]);_0x6edccf[_0xf3aa('0x26')][_0xf3aa('0x73')]=_0x6edccf['channel'];_0x6edccf[_0xf3aa('0x26')][_0xf3aa('0x74')]=_0xf3aa('0x5e');return respondWithRpcPromise(_0xf3aa('0x75'),_0xf3aa('0x75'),{'event':_0xf3aa('0x76'),'message':_0x6edccf['message']},client9002)[_0xf3aa('0x33')](function(){return _0x6edccf;});}return _0x6edccf;}return null;})[_0xf3aa('0x33')](respondWithResult(_0xaad47f,null))['catch'](handleError(_0xaad47f,null));};var interaction_log=require('../../config/logger')('sms-interactions');exports[_0xf3aa('0x30')]=function(_0x574e8d,_0x202e67,_0x15d5a5){var _0xcdb4f0={'agent':{},'channel':_0xf3aa('0x5f')};if(_0x574e8d[_0xf3aa('0x5b')]['id']){delete _0x574e8d['body']['id'];}_0x574e8d[_0xf3aa('0x5b')][_0xf3aa('0x62')]=_0x574e8d['body']['UserId']||_0x574e8d['user']['id'];_0xcdb4f0[_0xf3aa('0x64')]['id']=_0x574e8d[_0xf3aa('0x5b')][_0xf3aa('0x62')];return db[_0xf3aa('0x3a')]['find']({'where':{'id':_0x574e8d[_0xf3aa('0x56')]['id'],'UserId':null}})[_0xf3aa('0x33')](handleEntityNotFound(_0x202e67,null))[_0xf3aa('0x33')](function(_0x43b43d){if(_0x43b43d){_0xcdb4f0[_0xf3aa('0x26')]=_0x43b43d[_0xf3aa('0x67')]({'plain':!![]});return db['SmsInteraction'][_0xf3aa('0x59')]({'where':{'id':_0x43b43d[_0xf3aa('0x69')]}});}return null;})['then'](handleEntityNotFound(_0x202e67,null))[_0xf3aa('0x33')](function(_0x2fe68a){if(_0x2fe68a){_0xcdb4f0[_0xf3aa('0x77')]=_0x2fe68a['get']({'plain':!![]});interaction_log[_0xf3aa('0x6a')](_0xf3aa('0x78'),_0x574e8d[_0xf3aa('0x63')]['id'],_0x574e8d['user'][_0xf3aa('0x36')],_0x574e8d[_0xf3aa('0x63')][_0xf3aa('0x79')],_0xcdb4f0[_0xf3aa('0x77')]['id'],_0x574e8d[_0xf3aa('0x5b')]?JSON[_0xf3aa('0x6c')](_0x574e8d[_0xf3aa('0x5b')]):_0xf3aa('0x6d'));return respondWithRpcPromise(_0xf3aa('0x7a'),_0xf3aa('0x7b'),_0xcdb4f0);}return null;})[_0xf3aa('0x33')](function(_0x4304d0){if(_0x4304d0){_0x4304d0[_0xf3aa('0x26')][_0xf3aa('0x71')]=util[_0xf3aa('0x60')](_0xf3aa('0x72'),_0x574e8d[_0xf3aa('0x63')][_0xf3aa('0x36')]);_0x4304d0[_0xf3aa('0x26')][_0xf3aa('0x73')]=_0xcdb4f0[_0xf3aa('0x73')];_0x4304d0[_0xf3aa('0x26')][_0xf3aa('0x74')]=_0xf3aa('0x30');respondWithRpcPromise(_0xf3aa('0x75'),'EventManager',{'event':'rejectmessage','message':_0x4304d0['message']},client9002);return _0xcdb4f0;}return null;})['then'](respondWithResult(_0x202e67,null))[_0xf3aa('0x54')](handleError(_0x202e67,null));};exports[_0xf3aa('0x29')]=function(_0x1cefc6,_0x491df5,_0x1f4294){if(_0x1cefc6[_0xf3aa('0x5b')]['id']){delete _0x1cefc6[_0xf3aa('0x5b')]['id'];}var _0x49ec12;return db[_0xf3aa('0x3a')]['find']({'where':{'id':_0x1cefc6[_0xf3aa('0x56')]['id']}})[_0xf3aa('0x33')](handleEntityNotFound(_0x491df5,null))[_0xf3aa('0x33')](function(_0x123003){if(_0x123003){_0x49ec12=_0x123003;return db[_0xf3aa('0x7c')][_0xf3aa('0x59')]({'where':{'id':_0x123003[_0xf3aa('0x7d')]}});}})[_0xf3aa('0x33')](handleEntityNotFound(_0x491df5,null))[_0xf3aa('0x33')](function(_0x2f681f){if(_0x2f681f){logger[_0xf3aa('0x7e')](_0xf3aa('0x7f'),_0xf3aa('0x29'),'received\x20delivery\x20report\x20from',_0x2f681f[_0xf3aa('0x3d')],util[_0xf3aa('0x80')](_0x1cefc6[_0xf3aa('0x5b')],{'showHidden':![],'depth':null}));switch(_0x2f681f['type']){case _0xf3aa('0x81'):if(_0x1cefc6[_0xf3aa('0x5b')][_0xf3aa('0x82')]&&_0x1cefc6[_0xf3aa('0x5b')][_0xf3aa('0x82')]===_0x49ec12['messageId']){return _0x49ec12[_0xf3aa('0x31')]({'read':!![]});}else{logger[_0xf3aa('0x24')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0xf3aa('0x29'),_0xf3aa('0x81'),util[_0xf3aa('0x80')](_0x1cefc6['body'],{'showHidden':![],'depth':null}));}break;case _0xf3aa('0x83'):if(_0x1cefc6[_0xf3aa('0x5b')][_0xf3aa('0x84')]&&_0x1cefc6[_0xf3aa('0x5b')][_0xf3aa('0x84')]===_0x49ec12[_0xf3aa('0x85')]&&_[_0xf3aa('0x86')]([_0xf3aa('0x87'),'delivered'],_0x1cefc6[_0xf3aa('0x5b')]['Status'])>=0x0){return _0x49ec12[_0xf3aa('0x31')]({'read':!![]});}else{logger[_0xf3aa('0x24')](_0xf3aa('0x88'),'status',_0xf3aa('0x89'),util['inspect'](_0x1cefc6[_0xf3aa('0x5b')],{'showHidden':![],'depth':null}));}break;case'infobip':var _0xe77852=_0x1cefc6[_0xf3aa('0x5b')][_0xf3aa('0x8a')][0x0];if(_0xe77852[_0xf3aa('0x29')][_0xf3aa('0x8b')]===_0xf3aa('0x8c')){return _0x49ec12['update']({'read':!![]});}else{logger['error'](_0xf3aa('0x88'),'status',_0xf3aa('0x8d'),util[_0xf3aa('0x80')](_0x1cefc6[_0xf3aa('0x5b')],{'showHidden':![],'depth':null}));}break;}return _0x49ec12;}})['then'](respondWithResult(_0x491df5,null))[_0xf3aa('0x54')](handleError(_0x491df5,null));};
\ No newline at end of file
+var _0x943d=['SELECT','contact','User','fullname','internal','manual','interface','format','SIP/%s','channel','motionChannel','event','EventManager','acceptmessage','SmsInteractionId','[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','sequelize','email','rejectmessage','SmsAccount','SmsMessage,\x20%s,\x20%s,\x20%s','received\x20delivery\x20report\x20from','inspect','twilio','MessageSid','SmsAccount,\x20%s,\x20%s,\x20%s','MessageUUID','messageId','indexOf','sent','delivered','Status','plivio','infobip','results','groupName','DELIVERED','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./smsMessage.socket','register','client','request','info','SmsMessage,\x20%s,\x20%s','debug','stringify','error','code','message','request\x20sent','result','sendStatus','status','json','offset','limit','count','set','Content-Range','reject','save','update','then','destroy','end','name','index','SmsMessage','rawAttributes','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','includeAll','findAll','rows','show','params','include','options','find','catch','create','body','describe','../../config/logger','sms-interactions','accept','sms','read','readAt','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','SmsInteraction','interaction','[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','QueryTypes'];(function(_0x4f59e9,_0x530be0){var _0x29c814=function(_0x94190c){while(--_0x94190c){_0x4f59e9['push'](_0x4f59e9['shift']());}};_0x29c814(++_0x530be0);}(_0x943d,0x155));var _0xd943=function(_0x13b02f,_0x462a53){_0x13b02f=_0x13b02f-0x0;var _0x12e9a6=_0x943d[_0x13b02f];return _0x12e9a6;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xd943('0x0'));var zipdir=require(_0xd943('0x1'));var jsonpatch=require(_0xd943('0x2'));var rp=require(_0xd943('0x3'));var moment=require(_0xd943('0x4'));var BPromise=require(_0xd943('0x5'));var Mustache=require(_0xd943('0x6'));var util=require(_0xd943('0x7'));var path=require(_0xd943('0x8'));var sox=require(_0xd943('0x9'));var csv=require(_0xd943('0xa'));var ejs=require(_0xd943('0xb'));var fs=require('fs');var fs_extra=require(_0xd943('0xc'));var _=require(_0xd943('0xd'));var squel=require('squel');var crypto=require(_0xd943('0xe'));var jsforce=require(_0xd943('0xf'));var deskjs=require(_0xd943('0x10'));var toCsv=require(_0xd943('0xa'));var querystring=require('querystring');var Papa=require(_0xd943('0x11'));var Redis=require(_0xd943('0x12'));var authService=require(_0xd943('0x13'));var qs=require(_0xd943('0x14'));var as=require(_0xd943('0x15'));var hardwareService=require(_0xd943('0x16'));var logger=require('../../config/logger')('api');var utils=require(_0xd943('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0xd943('0x18'));var db=require(_0xd943('0x19'))['db'];config['redis']=_[_0xd943('0x1a')](config[_0xd943('0x1b')],{'host':_0xd943('0x1c'),'port':0x18eb});var socket=require(_0xd943('0x1d'))(new Redis(config['redis']));require(_0xd943('0x1e'))[_0xd943('0x1f')](socket);var jayson=require('jayson/promise');var client=jayson[_0xd943('0x20')]['http']({'port':0x232c});var client9002=jayson[_0xd943('0x20')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4977ca,_0x7c0693,_0x50ea2e,_0x4505d3){return new BPromise(function(_0x305e45,_0x509f87){var _0x500065=_0x4505d3||client;return _0x500065[_0xd943('0x21')](_0x4977ca,_0x50ea2e)['then'](function(_0x2e92ca){logger[_0xd943('0x22')](_0xd943('0x23'),_0x7c0693,'request\x20sent');logger[_0xd943('0x24')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x7c0693,'request\x20sent',JSON[_0xd943('0x25')](_0x2e92ca));if(_0x2e92ca[_0xd943('0x26')]){if(_0x2e92ca[_0xd943('0x26')][_0xd943('0x27')]===0x1f4){logger['error'](_0xd943('0x23'),_0x7c0693,_0x2e92ca[_0xd943('0x26')][_0xd943('0x28')]);return _0x509f87(_0x2e92ca['error'][_0xd943('0x28')]);}logger[_0xd943('0x26')](_0xd943('0x23'),_0x7c0693,_0x2e92ca[_0xd943('0x26')][_0xd943('0x28')]);return _0x305e45(_0x2e92ca[_0xd943('0x26')]['message']);}else{logger[_0xd943('0x22')](_0xd943('0x23'),_0x7c0693,_0xd943('0x29'));_0x305e45(_0x2e92ca[_0xd943('0x2a')][_0xd943('0x28')]);}})['catch'](function(_0x30f03c){logger['error']('SmsMessage,\x20%s,\x20%s',_0x7c0693,_0x30f03c);_0x509f87(_0x30f03c);});});}function respondWithStatusCode(_0x2ed385,_0x5c19b3){_0x5c19b3=_0x5c19b3||0xcc;return function(_0x3723dc){if(_0x3723dc){return _0x2ed385[_0xd943('0x2b')](_0x5c19b3);}return _0x2ed385[_0xd943('0x2c')](_0x5c19b3)['end']();};}function respondWithResult(_0x56c92f,_0x4f727b){_0x4f727b=_0x4f727b||0xc8;return function(_0x41a593){if(_0x41a593){return _0x56c92f[_0xd943('0x2c')](_0x4f727b)[_0xd943('0x2d')](_0x41a593);}};}function respondWithFilteredResult(_0xa3c0fe,_0x8cb4f8){return function(_0x33da71){if(_0x33da71){var _0x148803=typeof _0x8cb4f8[_0xd943('0x2e')]==='undefined'&&typeof _0x8cb4f8[_0xd943('0x2f')]==='undefined';var _0x1e53f4=_0x33da71[_0xd943('0x30')];var _0x5c3cc4=_0x148803?0x0:_0x8cb4f8[_0xd943('0x2e')];var _0x1327b1=_0x148803?_0x33da71['count']:_0x8cb4f8['offset']+_0x8cb4f8['limit'];var _0x21ad23;if(_0x1327b1>=_0x1e53f4){_0x1327b1=_0x1e53f4;_0x21ad23=0xc8;}else{_0x21ad23=0xce;}_0xa3c0fe['status'](_0x21ad23);return _0xa3c0fe[_0xd943('0x31')](_0xd943('0x32'),_0x5c3cc4+'-'+_0x1327b1+'/'+_0x1e53f4)['json'](_0x33da71);}return null;};}function patchUpdates(_0x156bb0){return function(_0x5b5d72){try{jsonpatch['apply'](_0x5b5d72,_0x156bb0,!![]);}catch(_0x16631c){return BPromise[_0xd943('0x33')](_0x16631c);}return _0x5b5d72[_0xd943('0x34')]();};}function saveUpdates(_0xd0219c,_0x3a7dab){return function(_0x4d3e53){if(_0x4d3e53){return _0x4d3e53[_0xd943('0x35')](_0xd0219c)[_0xd943('0x36')](function(_0x1af585){return _0x1af585;});}return null;};}function removeEntity(_0x19494f,_0x4a3108){return function(_0x16bfae){if(_0x16bfae){return _0x16bfae[_0xd943('0x37')]()[_0xd943('0x36')](function(){_0x19494f['status'](0xcc)[_0xd943('0x38')]();});}};}function handleEntityNotFound(_0x4b7ca1,_0x508d59){return function(_0x3ebd4f){if(!_0x3ebd4f){_0x4b7ca1['sendStatus'](0x194);}return _0x3ebd4f;};}function handleError(_0x461b3c,_0x47986b){_0x47986b=_0x47986b||0x1f4;return function(_0x5e8ccb){logger['error'](_0x5e8ccb['stack']);if(_0x5e8ccb[_0xd943('0x39')]){delete _0x5e8ccb['name'];}_0x461b3c[_0xd943('0x2c')](_0x47986b)['send'](_0x5e8ccb);};}exports[_0xd943('0x3a')]=function(_0x3335e5,_0x1e8aa6){var _0x480c95={},_0x59235b={},_0x4b35fb={'count':0x0,'rows':[]};var _0x1ce038=_['map'](db[_0xd943('0x3b')][_0xd943('0x3c')],function(_0xc9900f){return{'name':_0xc9900f['fieldName'],'type':_0xc9900f[_0xd943('0x3d')][_0xd943('0x3e')]};});_0x59235b[_0xd943('0x3f')]=_[_0xd943('0x40')](_0x1ce038,_0xd943('0x39'));_0x59235b[_0xd943('0x41')]=_[_0xd943('0x42')](_0x3335e5[_0xd943('0x41')]);_0x59235b[_0xd943('0x43')]=_[_0xd943('0x44')](_0x59235b[_0xd943('0x3f')],_0x59235b['query']);_0x480c95[_0xd943('0x45')]=_[_0xd943('0x44')](_0x59235b['model'],qs[_0xd943('0x46')](_0x3335e5['query'][_0xd943('0x46')]));_0x480c95[_0xd943('0x45')]=_0x480c95['attributes'][_0xd943('0x47')]?_0x480c95[_0xd943('0x45')]:_0x59235b['model'];if(!_0x3335e5[_0xd943('0x41')][_0xd943('0x48')](_0xd943('0x49'))){_0x480c95[_0xd943('0x2f')]=qs[_0xd943('0x2f')](_0x3335e5[_0xd943('0x41')][_0xd943('0x2f')]);_0x480c95[_0xd943('0x2e')]=qs[_0xd943('0x2e')](_0x3335e5[_0xd943('0x41')]['offset']);}_0x480c95[_0xd943('0x4a')]=qs[_0xd943('0x4b')](_0x3335e5[_0xd943('0x41')][_0xd943('0x4b')]);_0x480c95[_0xd943('0x4c')]=qs[_0xd943('0x43')](_[_0xd943('0x4d')](_0x3335e5['query'],_0x59235b['filters']),_0x1ce038);if(_0x3335e5[_0xd943('0x41')]['filter']){_0x480c95[_0xd943('0x4c')]=_[_0xd943('0x4e')](_0x480c95[_0xd943('0x4c')],{'$or':_[_0xd943('0x40')](_0x1ce038,function(_0x44c582){if(_0x44c582[_0xd943('0x3d')]!==_0xd943('0x4f')){var _0x1c0c94={};_0x1c0c94[_0x44c582[_0xd943('0x39')]]={'$like':'%'+_0x3335e5[_0xd943('0x41')][_0xd943('0x50')]+'%'};return _0x1c0c94;}})});}_0x480c95=_[_0xd943('0x4e')]({},_0x480c95,_0x3335e5['options']);var _0x4d4141={'where':_0x480c95[_0xd943('0x4c')]};return db[_0xd943('0x3b')][_0xd943('0x30')](_0x4d4141)[_0xd943('0x36')](function(_0x4df001){_0x4b35fb[_0xd943('0x30')]=_0x4df001;if(_0x3335e5[_0xd943('0x41')][_0xd943('0x51')]){_0x480c95['include']=[{'all':!![]}];}return db[_0xd943('0x3b')][_0xd943('0x52')](_0x480c95);})[_0xd943('0x36')](function(_0x2712ba){_0x4b35fb[_0xd943('0x53')]=_0x2712ba;return _0x4b35fb;})[_0xd943('0x36')](respondWithFilteredResult(_0x1e8aa6,_0x480c95))['catch'](handleError(_0x1e8aa6,null));};exports[_0xd943('0x54')]=function(_0x242f77,_0x32bee0){var _0x20f256={'raw':!![],'where':{'id':_0x242f77[_0xd943('0x55')]['id']}},_0x39f6b8={};_0x39f6b8[_0xd943('0x3f')]=_[_0xd943('0x42')](db[_0xd943('0x3b')]['rawAttributes']);_0x39f6b8[_0xd943('0x41')]=_['keys'](_0x242f77['query']);_0x39f6b8['filters']=_[_0xd943('0x44')](_0x39f6b8[_0xd943('0x3f')],_0x39f6b8[_0xd943('0x41')]);_0x20f256[_0xd943('0x45')]=_[_0xd943('0x44')](_0x39f6b8['model'],qs[_0xd943('0x46')](_0x242f77['query']['fields']));_0x20f256['attributes']=_0x20f256[_0xd943('0x45')][_0xd943('0x47')]?_0x20f256[_0xd943('0x45')]:_0x39f6b8['model'];if(_0x242f77[_0xd943('0x41')][_0xd943('0x51')]){_0x20f256[_0xd943('0x56')]=[{'all':!![]}];}_0x20f256=_[_0xd943('0x4e')]({},_0x20f256,_0x242f77[_0xd943('0x57')]);return db['SmsMessage'][_0xd943('0x58')](_0x20f256)[_0xd943('0x36')](handleEntityNotFound(_0x32bee0,null))[_0xd943('0x36')](respondWithResult(_0x32bee0,null))[_0xd943('0x59')](handleError(_0x32bee0,null));};exports[_0xd943('0x5a')]=function(_0x4ed38a,_0x51cd16){return db[_0xd943('0x3b')][_0xd943('0x5a')](_0x4ed38a[_0xd943('0x5b')],{})[_0xd943('0x36')](respondWithResult(_0x51cd16,0xc9))[_0xd943('0x59')](handleError(_0x51cd16,null));};exports[_0xd943('0x35')]=function(_0x4fb33a,_0x145124){if(_0x4fb33a[_0xd943('0x5b')]['id']){delete _0x4fb33a[_0xd943('0x5b')]['id'];}return db[_0xd943('0x3b')][_0xd943('0x58')]({'where':{'id':_0x4fb33a[_0xd943('0x55')]['id']}})[_0xd943('0x36')](handleEntityNotFound(_0x145124,null))[_0xd943('0x36')](saveUpdates(_0x4fb33a[_0xd943('0x5b')],null))['then'](respondWithResult(_0x145124,null))[_0xd943('0x59')](handleError(_0x145124,null));};exports[_0xd943('0x37')]=function(_0x500112,_0x1360ef){return db['SmsMessage'][_0xd943('0x58')]({'where':{'id':_0x500112[_0xd943('0x55')]['id']}})[_0xd943('0x36')](handleEntityNotFound(_0x1360ef,null))[_0xd943('0x36')](removeEntity(_0x1360ef,null))[_0xd943('0x59')](handleError(_0x1360ef,null));};exports[_0xd943('0x5c')]=function(_0x52d44b,_0x373732){return db[_0xd943('0x3b')][_0xd943('0x5c')]()[_0xd943('0x36')](respondWithResult(_0x373732,null))['catch'](handleError(_0x373732,null));};var interaction_log=require(_0xd943('0x5d'))(_0xd943('0x5e'));exports[_0xd943('0x5f')]=function(_0x11747e,_0x31e20c,_0x56ce34){var _0x2c9422={'agent':{},'channel':_0xd943('0x60')};if(_0x11747e['body']['id']){delete _0x11747e[_0xd943('0x5b')]['id'];}_0x11747e[_0xd943('0x5b')][_0xd943('0x61')]=!![];_0x11747e[_0xd943('0x5b')][_0xd943('0x62')]=moment()['format'](_0xd943('0x63'));_0x11747e[_0xd943('0x5b')][_0xd943('0x64')]=_0x11747e[_0xd943('0x5b')][_0xd943('0x64')]||_0x11747e[_0xd943('0x65')]['id'];_0x2c9422[_0xd943('0x66')]['id']=_0x11747e[_0xd943('0x5b')]['UserId'];return db[_0xd943('0x3b')][_0xd943('0x58')]({'where':{'id':_0x11747e[_0xd943('0x55')]['id'],'UserId':null}})[_0xd943('0x36')](handleEntityNotFound(_0x31e20c,null))[_0xd943('0x36')](saveUpdates(_0x11747e['body'],null))[_0xd943('0x36')](function(_0x3bd674){if(_0x3bd674){_0x2c9422[_0xd943('0x28')]=_0x3bd674[_0xd943('0x67')]({'plain':!![]});return db[_0xd943('0x68')][_0xd943('0x58')]({'where':{'id':_0x3bd674['SmsInteractionId']}});}return null;})[_0xd943('0x36')](handleEntityNotFound(_0x31e20c,null))[_0xd943('0x36')](function(_0x24693c){if(_0x24693c){return _0x24693c[_0xd943('0x35')]({'UserId':_0x11747e[_0xd943('0x5b')][_0xd943('0x64')],'read1stAt':_['isNil'](_0x24693c['read1stAt'])?moment()['format'](_0xd943('0x63')):undefined});}return null;})[_0xd943('0x36')](function(_0x11a72b){if(_0x11a72b){_0x2c9422[_0xd943('0x69')]=_0x11a72b[_0xd943('0x67')]({'plain':!![]});interaction_log[_0xd943('0x22')](_0xd943('0x6a'),_0x11747e[_0xd943('0x65')]['id'],_0x11747e[_0xd943('0x65')][_0xd943('0x39')],_0x11747e[_0xd943('0x65')][_0xd943('0x6b')],_0x2c9422[_0xd943('0x69')]['id'],_0x11747e[_0xd943('0x5b')]?JSON['stringify'](_0x11747e[_0xd943('0x5b')]):_0xd943('0x6c'));return respondWithRpcPromise(_0xd943('0x6d'),_0xd943('0x6e'),_0x2c9422);}return null;})[_0xd943('0x36')](function(_0x515dd8){var _0x1d1824=_0xd943('0x6f')+_0x515dd8[_0xd943('0x28')][_0xd943('0x70')];return db['sequelize'][_0xd943('0x41')](_0x1d1824,{'type':db[_0xd943('0x71')][_0xd943('0x72')][_0xd943('0x73')],'raw':!![]})['then'](function(_0x25d75a){return _0x25d75a;});})[_0xd943('0x36')](function(_0x2ef8e9){if(_0x2ef8e9){_0x2c9422['message'][_0xd943('0x74')]=_0x2ef8e9[0x0];if(!_0x11747e[_0xd943('0x5b')][_0xd943('0x64')])return;return db[_0xd943('0x75')]['find']({'where':{'id':_0x11747e[_0xd943('0x5b')][_0xd943('0x64')],'role':_0xd943('0x66')},'attributes':['id','name',_0xd943('0x76'),'email',_0xd943('0x77')],'raw':!![]});}return null;})[_0xd943('0x36')](function(_0x1b9205){if(!_0x1b9205)return null;_0x2c9422[_0xd943('0x28')][_0xd943('0x66')]=_0x1b9205;return _0x2c9422;})[_0xd943('0x36')](function(_0x142d6d){if(_0x142d6d){if(_0x11747e[_0xd943('0x5b')][_0xd943('0x78')]){_0x2c9422['message'][_0xd943('0x79')]=util[_0xd943('0x7a')](_0xd943('0x7b'),_0x11747e[_0xd943('0x65')]['name']);_0x2c9422[_0xd943('0x28')][_0xd943('0x7c')]=_0x2c9422[_0xd943('0x7c')];_0x2c9422['message'][_0xd943('0x7d')]=_0x2c9422['channel'];_0x2c9422[_0xd943('0x28')][_0xd943('0x7e')]=_0xd943('0x5f');return respondWithRpcPromise(_0xd943('0x7f'),_0xd943('0x7f'),{'event':_0xd943('0x80'),'message':_0x2c9422[_0xd943('0x28')]},client9002)[_0xd943('0x36')](function(){return _0x2c9422;});}return _0x2c9422;}return null;})[_0xd943('0x36')](respondWithResult(_0x31e20c,null))[_0xd943('0x59')](handleError(_0x31e20c,null));};var interaction_log=require(_0xd943('0x5d'))('sms-interactions');exports[_0xd943('0x33')]=function(_0x477331,_0x4d69ec,_0x60602f){var _0x58cdb1={'agent':{},'channel':_0xd943('0x60')};if(_0x477331[_0xd943('0x5b')]['id']){delete _0x477331[_0xd943('0x5b')]['id'];}_0x477331[_0xd943('0x5b')]['UserId']=_0x477331[_0xd943('0x5b')][_0xd943('0x64')]||_0x477331[_0xd943('0x65')]['id'];_0x58cdb1[_0xd943('0x66')]['id']=_0x477331['body'][_0xd943('0x64')];return db[_0xd943('0x3b')][_0xd943('0x58')]({'where':{'id':_0x477331[_0xd943('0x55')]['id'],'UserId':null}})[_0xd943('0x36')](handleEntityNotFound(_0x4d69ec,null))[_0xd943('0x36')](function(_0x4b8dc0){if(_0x4b8dc0){_0x58cdb1[_0xd943('0x28')]=_0x4b8dc0[_0xd943('0x67')]({'plain':!![]});return db[_0xd943('0x68')][_0xd943('0x58')]({'where':{'id':_0x4b8dc0[_0xd943('0x81')]}});}return null;})[_0xd943('0x36')](handleEntityNotFound(_0x4d69ec,null))[_0xd943('0x36')](function(_0x1e54e4){if(_0x1e54e4){_0x58cdb1[_0xd943('0x69')]=_0x1e54e4[_0xd943('0x67')]({'plain':!![]});interaction_log[_0xd943('0x22')](_0xd943('0x82'),_0x477331[_0xd943('0x65')]['id'],_0x477331[_0xd943('0x65')][_0xd943('0x39')],_0x477331[_0xd943('0x65')][_0xd943('0x6b')],_0x58cdb1[_0xd943('0x69')]['id'],_0x477331[_0xd943('0x5b')]?JSON[_0xd943('0x25')](_0x477331[_0xd943('0x5b')]):_0xd943('0x6c'));return respondWithRpcPromise('RejectMessage','rejectMessage',_0x58cdb1);}return null;})[_0xd943('0x36')](function(_0x1798bb){var _0x28ef6a=_0xd943('0x6f')+_0x1798bb['message'][_0xd943('0x70')];return db[_0xd943('0x83')][_0xd943('0x41')](_0x28ef6a,{'type':db[_0xd943('0x71')]['QueryTypes'][_0xd943('0x73')],'raw':!![]})[_0xd943('0x36')](function(_0x5736da){return _0x5736da;});})[_0xd943('0x36')](function(_0x36c0c5){if(_0x36c0c5){_0x58cdb1[_0xd943('0x28')]['contact']=_0x36c0c5[0x0];if(!_0x477331[_0xd943('0x5b')][_0xd943('0x64')])return;return db[_0xd943('0x75')][_0xd943('0x58')]({'where':{'id':_0x477331[_0xd943('0x5b')][_0xd943('0x64')],'role':_0xd943('0x66')},'attributes':['id',_0xd943('0x39'),_0xd943('0x76'),_0xd943('0x84'),_0xd943('0x77')],'raw':!![]});}return null;})[_0xd943('0x36')](function(_0x155b8c){if(!_0x155b8c)return null;_0x58cdb1[_0xd943('0x28')][_0xd943('0x66')]=_0x155b8c;return _0x58cdb1;})[_0xd943('0x36')](function(_0x537f49){if(_0x537f49){_0x537f49[_0xd943('0x28')][_0xd943('0x79')]=util[_0xd943('0x7a')](_0xd943('0x7b'),_0x477331[_0xd943('0x65')][_0xd943('0x39')]);_0x537f49[_0xd943('0x28')][_0xd943('0x7c')]=_0x58cdb1[_0xd943('0x7c')];_0x537f49[_0xd943('0x28')][_0xd943('0x7d')]=_0x58cdb1[_0xd943('0x7c')];_0x537f49[_0xd943('0x28')][_0xd943('0x7e')]='reject';respondWithRpcPromise(_0xd943('0x7f'),'EventManager',{'event':_0xd943('0x85'),'message':_0x537f49[_0xd943('0x28')]},client9002);return _0x58cdb1;}return null;})['then'](respondWithResult(_0x4d69ec,null))[_0xd943('0x59')](handleError(_0x4d69ec,null));};exports[_0xd943('0x2c')]=function(_0x172ecb,_0x40c188,_0x3ea46b){if(_0x172ecb[_0xd943('0x5b')]['id']){delete _0x172ecb[_0xd943('0x5b')]['id'];}var _0xc58205;return db[_0xd943('0x3b')][_0xd943('0x58')]({'where':{'id':_0x172ecb[_0xd943('0x55')]['id']}})[_0xd943('0x36')](handleEntityNotFound(_0x40c188,null))[_0xd943('0x36')](function(_0xd8991a){if(_0xd8991a){_0xc58205=_0xd8991a;return db[_0xd943('0x86')][_0xd943('0x58')]({'where':{'id':_0xd8991a['SmsAccountId']}});}})[_0xd943('0x36')](handleEntityNotFound(_0x40c188,null))[_0xd943('0x36')](function(_0x3ce809){if(_0x3ce809){logger[_0xd943('0x24')](_0xd943('0x87'),_0xd943('0x2c'),_0xd943('0x88'),_0x3ce809[_0xd943('0x3d')],util[_0xd943('0x89')](_0x172ecb[_0xd943('0x5b')],{'showHidden':![],'depth':null}));switch(_0x3ce809[_0xd943('0x3d')]){case _0xd943('0x8a'):if(_0x172ecb[_0xd943('0x5b')][_0xd943('0x8b')]&&_0x172ecb[_0xd943('0x5b')][_0xd943('0x8b')]===_0xc58205['messageId']){return _0xc58205['update']({'read':!![]});}else{logger[_0xd943('0x26')](_0xd943('0x8c'),_0xd943('0x2c'),_0xd943('0x8a'),util[_0xd943('0x89')](_0x172ecb['body'],{'showHidden':![],'depth':null}));}break;case'plivo':if(_0x172ecb[_0xd943('0x5b')]['MessageUUID']&&_0x172ecb[_0xd943('0x5b')][_0xd943('0x8d')]===_0xc58205[_0xd943('0x8e')]&&_[_0xd943('0x8f')]([_0xd943('0x90'),_0xd943('0x91')],_0x172ecb[_0xd943('0x5b')][_0xd943('0x92')])>=0x0){return _0xc58205[_0xd943('0x35')]({'read':!![]});}else{logger[_0xd943('0x26')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0xd943('0x2c'),_0xd943('0x93'),util[_0xd943('0x89')](_0x172ecb['body'],{'showHidden':![],'depth':null}));}break;case _0xd943('0x94'):var _0xdf1a5c=_0x172ecb[_0xd943('0x5b')][_0xd943('0x95')][0x0];if(_0xdf1a5c[_0xd943('0x2c')][_0xd943('0x96')]===_0xd943('0x97')){return _0xc58205[_0xd943('0x35')]({'read':!![]});}else{logger[_0xd943('0x26')](_0xd943('0x8c'),'status',_0xd943('0x94'),util[_0xd943('0x89')](_0x172ecb[_0xd943('0x5b')],{'showHidden':![],'depth':null}));}break;}return _0xc58205;}})['then'](respondWithResult(_0x40c188,null))['catch'](handleError(_0x40c188,null));};
\ No newline at end of file