Built motion from commit ab870f9e.|2.5.44
[motion2.git] / server / api / smsMessage / smsMessage.controller.js
index a9c5831..582774f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0f84=['rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','localhost','./smsMessage.socket','register','jayson/promise','client','http','request','info','SmsMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','sendStatus','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','destroy','status','end','stack','name','send','index','map','SmsMessage','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','order','sort','where','filter','VIRTUAL','merge','options','includeAll','include','findAll','show','params','rawAttributes','length','find','create','body','describe','sms-interactions','accept','sms','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','user','agent','UserId','get','SmsInteraction','SmsInteractionId','read1stAt','interaction','role','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','QueryTypes','SELECT','contact','fullname','email','internal','interface','channel','EventManager','acceptmessage','[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','sequelize','SIP/%s','event','SmsAccountId','SmsMessage,\x20%s,\x20%s,\x20%s','inspect','twilio','MessageSid','messageId','SmsAccount,\x20%s,\x20%s,\x20%s','plivo','MessageUUID','delivered','Status','plivio','infobip','results','groupName','DELIVERED'];(function(_0x3bc138,_0x55d3ed){var _0x2e49a4=function(_0x536856){while(--_0x536856){_0x3bc138['push'](_0x3bc138['shift']());}};_0x2e49a4(++_0x55d3ed);}(_0x0f84,0x11c));var _0x40f8=function(_0x540d2d,_0x4438b2){_0x540d2d=_0x540d2d-0x0;var _0x2faf3a=_0x0f84[_0x540d2d];return _0x2faf3a;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x40f8('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x40f8('0x1'));var rp=require(_0x40f8('0x2'));var moment=require(_0x40f8('0x3'));var BPromise=require(_0x40f8('0x4'));var Mustache=require(_0x40f8('0x5'));var util=require(_0x40f8('0x6'));var path=require(_0x40f8('0x7'));var sox=require(_0x40f8('0x8'));var csv=require('to-csv');var ejs=require(_0x40f8('0x9'));var fs=require('fs');var fs_extra=require(_0x40f8('0xa'));var _=require(_0x40f8('0xb'));var squel=require('squel');var crypto=require(_0x40f8('0xc'));var jsforce=require(_0x40f8('0xd'));var deskjs=require(_0x40f8('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x40f8('0xf'));var Redis=require('ioredis');var authService=require(_0x40f8('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x40f8('0x11'));var hardwareService=require(_0x40f8('0x12'));var logger=require(_0x40f8('0x13'))(_0x40f8('0x14'));var utils=require(_0x40f8('0x15'));var config=require(_0x40f8('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x40f8('0x17'))['db'];config['redis']=_[_0x40f8('0x18')](config[_0x40f8('0x19')],{'host':_0x40f8('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x40f8('0x19')]));require(_0x40f8('0x1b'))[_0x40f8('0x1c')](socket);var jayson=require(_0x40f8('0x1d'));var client=jayson[_0x40f8('0x1e')][_0x40f8('0x1f')]({'port':0x232c});var client9002=jayson['client'][_0x40f8('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x56ba6b,_0x394ee5,_0x1236bc,_0x6922bf){return new BPromise(function(_0x48c221,_0x3f205b){var _0x2e9949=_0x6922bf||client;return _0x2e9949[_0x40f8('0x20')](_0x56ba6b,_0x1236bc)['then'](function(_0x4462f6){logger[_0x40f8('0x21')](_0x40f8('0x22'),_0x394ee5,_0x40f8('0x23'));logger[_0x40f8('0x24')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x394ee5,_0x40f8('0x23'),JSON[_0x40f8('0x25')](_0x4462f6));if(_0x4462f6[_0x40f8('0x26')]){if(_0x4462f6[_0x40f8('0x26')]['code']===0x1f4){logger[_0x40f8('0x26')](_0x40f8('0x22'),_0x394ee5,_0x4462f6[_0x40f8('0x26')][_0x40f8('0x27')]);return _0x3f205b(_0x4462f6[_0x40f8('0x26')][_0x40f8('0x27')]);}logger['error']('SmsMessage,\x20%s,\x20%s',_0x394ee5,_0x4462f6['error'][_0x40f8('0x27')]);return _0x48c221(_0x4462f6[_0x40f8('0x26')][_0x40f8('0x27')]);}else{logger[_0x40f8('0x21')]('SmsMessage,\x20%s,\x20%s',_0x394ee5,_0x40f8('0x23'));_0x48c221(_0x4462f6[_0x40f8('0x28')][_0x40f8('0x27')]);}})[_0x40f8('0x29')](function(_0x5a0278){logger[_0x40f8('0x26')](_0x40f8('0x22'),_0x394ee5,_0x5a0278);_0x3f205b(_0x5a0278);});});}function respondWithStatusCode(_0x5a1848,_0x5e2b51){_0x5e2b51=_0x5e2b51||0xcc;return function(_0x469df4){if(_0x469df4){return _0x5a1848[_0x40f8('0x2a')](_0x5e2b51);}return _0x5a1848['status'](_0x5e2b51)['end']();};}function respondWithResult(_0x284575,_0x411bcd){_0x411bcd=_0x411bcd||0xc8;return function(_0x35ff1f){if(_0x35ff1f){return _0x284575['status'](_0x411bcd)['json'](_0x35ff1f);}};}function respondWithFilteredResult(_0x463f1d,_0x5babb2){return function(_0x32c88e){if(_0x32c88e){var _0x66c125=typeof _0x5babb2[_0x40f8('0x2b')]===_0x40f8('0x2c')&&typeof _0x5babb2[_0x40f8('0x2d')]===_0x40f8('0x2c');var _0x4d665f=_0x32c88e['count'];var _0x4d3997=_0x66c125?0x0:_0x5babb2['offset'];var _0x2a49cb=_0x66c125?_0x32c88e[_0x40f8('0x2e')]:_0x5babb2[_0x40f8('0x2b')]+_0x5babb2[_0x40f8('0x2d')];var _0xc997f2;if(_0x2a49cb>=_0x4d665f){_0x2a49cb=_0x4d665f;_0xc997f2=0xc8;}else{_0xc997f2=0xce;}_0x463f1d['status'](_0xc997f2);return _0x463f1d['set'](_0x40f8('0x2f'),_0x4d3997+'-'+_0x2a49cb+'/'+_0x4d665f)['json'](_0x32c88e);}return null;};}function patchUpdates(_0x1ddef8){return function(_0x27a007){try{jsonpatch[_0x40f8('0x30')](_0x27a007,_0x1ddef8,!![]);}catch(_0x4f9ab1){return BPromise[_0x40f8('0x31')](_0x4f9ab1);}return _0x27a007[_0x40f8('0x32')]();};}function saveUpdates(_0xc758af,_0x411462){return function(_0x4762f0){if(_0x4762f0){return _0x4762f0[_0x40f8('0x33')](_0xc758af)[_0x40f8('0x34')](function(_0x2828e9){return _0x2828e9;});}return null;};}function removeEntity(_0xff2f11,_0x3f7db9){return function(_0x32a1ae){if(_0x32a1ae){return _0x32a1ae[_0x40f8('0x35')]()[_0x40f8('0x34')](function(){_0xff2f11[_0x40f8('0x36')](0xcc)[_0x40f8('0x37')]();});}};}function handleEntityNotFound(_0x3ab9d3,_0x4e7d4e){return function(_0x20ef66){if(!_0x20ef66){_0x3ab9d3[_0x40f8('0x2a')](0x194);}return _0x20ef66;};}function handleError(_0xa93171,_0x1d4928){_0x1d4928=_0x1d4928||0x1f4;return function(_0x5113c7){logger[_0x40f8('0x26')](_0x5113c7[_0x40f8('0x38')]);if(_0x5113c7['name']){delete _0x5113c7[_0x40f8('0x39')];}_0xa93171[_0x40f8('0x36')](_0x1d4928)[_0x40f8('0x3a')](_0x5113c7);};}exports[_0x40f8('0x3b')]=function(_0x436195,_0x8ada24){var _0x4e6f80={},_0x3d20de={},_0x20b944={'count':0x0,'rows':[]};var _0x454244=_[_0x40f8('0x3c')](db[_0x40f8('0x3d')]['rawAttributes'],function(_0xf91597){return{'name':_0xf91597[_0x40f8('0x3e')],'type':_0xf91597[_0x40f8('0x3f')][_0x40f8('0x40')]};});_0x3d20de[_0x40f8('0x41')]=_[_0x40f8('0x3c')](_0x454244,_0x40f8('0x39'));_0x3d20de[_0x40f8('0x42')]=_[_0x40f8('0x43')](_0x436195['query']);_0x3d20de[_0x40f8('0x44')]=_[_0x40f8('0x45')](_0x3d20de[_0x40f8('0x41')],_0x3d20de[_0x40f8('0x42')]);_0x4e6f80[_0x40f8('0x46')]=_[_0x40f8('0x45')](_0x3d20de[_0x40f8('0x41')],qs[_0x40f8('0x47')](_0x436195[_0x40f8('0x42')]['fields']));_0x4e6f80['attributes']=_0x4e6f80[_0x40f8('0x46')]['length']?_0x4e6f80[_0x40f8('0x46')]:_0x3d20de[_0x40f8('0x41')];if(!_0x436195[_0x40f8('0x42')]['hasOwnProperty']('nolimit')){_0x4e6f80[_0x40f8('0x2d')]=qs[_0x40f8('0x2d')](_0x436195['query'][_0x40f8('0x2d')]);_0x4e6f80[_0x40f8('0x2b')]=qs[_0x40f8('0x2b')](_0x436195[_0x40f8('0x42')][_0x40f8('0x2b')]);}_0x4e6f80[_0x40f8('0x48')]=qs[_0x40f8('0x49')](_0x436195[_0x40f8('0x42')][_0x40f8('0x49')]);_0x4e6f80[_0x40f8('0x4a')]=qs[_0x40f8('0x44')](_['pick'](_0x436195[_0x40f8('0x42')],_0x3d20de['filters']),_0x454244);if(_0x436195[_0x40f8('0x42')][_0x40f8('0x4b')]){_0x4e6f80['where']=_['merge'](_0x4e6f80[_0x40f8('0x4a')],{'$or':_['map'](_0x454244,function(_0x5580df){if(_0x5580df[_0x40f8('0x3f')]!==_0x40f8('0x4c')){var _0x1bd3f1={};_0x1bd3f1[_0x5580df[_0x40f8('0x39')]]={'$like':'%'+_0x436195[_0x40f8('0x42')]['filter']+'%'};return _0x1bd3f1;}})});}_0x4e6f80=_[_0x40f8('0x4d')]({},_0x4e6f80,_0x436195[_0x40f8('0x4e')]);var _0x261f7f={'where':_0x4e6f80[_0x40f8('0x4a')]};return db['SmsMessage'][_0x40f8('0x2e')](_0x261f7f)[_0x40f8('0x34')](function(_0x1bcced){_0x20b944['count']=_0x1bcced;if(_0x436195['query'][_0x40f8('0x4f')]){_0x4e6f80[_0x40f8('0x50')]=[{'all':!![]}];}return db[_0x40f8('0x3d')][_0x40f8('0x51')](_0x4e6f80);})['then'](function(_0x3f650e){_0x20b944['rows']=_0x3f650e;return _0x20b944;})[_0x40f8('0x34')](respondWithFilteredResult(_0x8ada24,_0x4e6f80))[_0x40f8('0x29')](handleError(_0x8ada24,null));};exports[_0x40f8('0x52')]=function(_0x57a3b8,_0x578fe6){var _0x414f03={'raw':!![],'where':{'id':_0x57a3b8[_0x40f8('0x53')]['id']}},_0x542817={};_0x542817[_0x40f8('0x41')]=_[_0x40f8('0x43')](db[_0x40f8('0x3d')][_0x40f8('0x54')]);_0x542817[_0x40f8('0x42')]=_[_0x40f8('0x43')](_0x57a3b8['query']);_0x542817[_0x40f8('0x44')]=_['intersection'](_0x542817['model'],_0x542817['query']);_0x414f03[_0x40f8('0x46')]=_[_0x40f8('0x45')](_0x542817[_0x40f8('0x41')],qs[_0x40f8('0x47')](_0x57a3b8[_0x40f8('0x42')][_0x40f8('0x47')]));_0x414f03[_0x40f8('0x46')]=_0x414f03[_0x40f8('0x46')][_0x40f8('0x55')]?_0x414f03[_0x40f8('0x46')]:_0x542817['model'];if(_0x57a3b8[_0x40f8('0x42')]['includeAll']){_0x414f03[_0x40f8('0x50')]=[{'all':!![]}];}_0x414f03=_[_0x40f8('0x4d')]({},_0x414f03,_0x57a3b8[_0x40f8('0x4e')]);return db[_0x40f8('0x3d')][_0x40f8('0x56')](_0x414f03)[_0x40f8('0x34')](handleEntityNotFound(_0x578fe6,null))['then'](respondWithResult(_0x578fe6,null))[_0x40f8('0x29')](handleError(_0x578fe6,null));};exports['create']=function(_0x28a781,_0x18dd7d){return db[_0x40f8('0x3d')][_0x40f8('0x57')](_0x28a781['body'],{})[_0x40f8('0x34')](respondWithResult(_0x18dd7d,0xc9))['catch'](handleError(_0x18dd7d,null));};exports[_0x40f8('0x33')]=function(_0x504928,_0x39609c){if(_0x504928[_0x40f8('0x58')]['id']){delete _0x504928[_0x40f8('0x58')]['id'];}return db['SmsMessage']['find']({'where':{'id':_0x504928['params']['id']}})[_0x40f8('0x34')](handleEntityNotFound(_0x39609c,null))[_0x40f8('0x34')](saveUpdates(_0x504928['body'],null))[_0x40f8('0x34')](respondWithResult(_0x39609c,null))['catch'](handleError(_0x39609c,null));};exports['destroy']=function(_0x68ec21,_0x14ece0){return db[_0x40f8('0x3d')][_0x40f8('0x56')]({'where':{'id':_0x68ec21['params']['id']}})[_0x40f8('0x34')](handleEntityNotFound(_0x14ece0,null))[_0x40f8('0x34')](removeEntity(_0x14ece0,null))[_0x40f8('0x29')](handleError(_0x14ece0,null));};exports[_0x40f8('0x59')]=function(_0xfb8987,_0x537347){return db['SmsMessage'][_0x40f8('0x59')]()[_0x40f8('0x34')](respondWithResult(_0x537347,null))[_0x40f8('0x29')](handleError(_0x537347,null));};var interaction_log=require(_0x40f8('0x13'))(_0x40f8('0x5a'));exports[_0x40f8('0x5b')]=function(_0x36df62,_0x49c5f6,_0x55e07b){var _0x3b7ee1={'agent':{},'channel':_0x40f8('0x5c')};if(_0x36df62[_0x40f8('0x58')]['id']){delete _0x36df62[_0x40f8('0x58')]['id'];}_0x36df62[_0x40f8('0x58')][_0x40f8('0x5d')]=!![];_0x36df62['body'][_0x40f8('0x5e')]=moment()[_0x40f8('0x5f')](_0x40f8('0x60'));_0x36df62['body']['UserId']=_0x36df62[_0x40f8('0x58')]['UserId']||_0x36df62[_0x40f8('0x61')]['id'];_0x3b7ee1[_0x40f8('0x62')]['id']=_0x36df62[_0x40f8('0x58')][_0x40f8('0x63')];return db['SmsMessage'][_0x40f8('0x56')]({'where':{'id':_0x36df62[_0x40f8('0x53')]['id'],'UserId':null}})[_0x40f8('0x34')](handleEntityNotFound(_0x49c5f6,null))['then'](saveUpdates(_0x36df62[_0x40f8('0x58')],null))[_0x40f8('0x34')](function(_0x21ec2d){if(_0x21ec2d){_0x3b7ee1[_0x40f8('0x27')]=_0x21ec2d[_0x40f8('0x64')]({'plain':!![]});return db[_0x40f8('0x65')][_0x40f8('0x56')]({'where':{'id':_0x21ec2d[_0x40f8('0x66')]}});}return null;})[_0x40f8('0x34')](handleEntityNotFound(_0x49c5f6,null))[_0x40f8('0x34')](function(_0x29a555){if(_0x29a555){return _0x29a555[_0x40f8('0x33')]({'UserId':_0x36df62[_0x40f8('0x58')][_0x40f8('0x63')],'read1stAt':_['isNil'](_0x29a555[_0x40f8('0x67')])?moment()[_0x40f8('0x5f')](_0x40f8('0x60')):undefined});}return null;})['then'](function(_0x16fd0b){if(_0x16fd0b){_0x3b7ee1[_0x40f8('0x68')]=_0x16fd0b[_0x40f8('0x64')]({'plain':!![]});interaction_log[_0x40f8('0x21')]('[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x36df62[_0x40f8('0x61')]['id'],_0x36df62['user']['name'],_0x36df62['user'][_0x40f8('0x69')],_0x3b7ee1[_0x40f8('0x68')]['id'],_0x36df62['body']?JSON['stringify'](_0x36df62[_0x40f8('0x58')]):'null');return respondWithRpcPromise('AcceptMessage',_0x40f8('0x6a'),_0x3b7ee1);}return null;})['then'](function(_0x4de3c3){var _0x4f9816=_0x40f8('0x6b')+_0x4de3c3[_0x40f8('0x27')][_0x40f8('0x6c')];return db['sequelize'][_0x40f8('0x42')](_0x4f9816,{'type':db[_0x40f8('0x6d')][_0x40f8('0x6e')][_0x40f8('0x6f')],'raw':!![]})[_0x40f8('0x34')](function(_0x3d68bb){return _0x3d68bb;});})[_0x40f8('0x34')](function(_0x5a2a59){if(_0x5a2a59){_0x3b7ee1[_0x40f8('0x27')][_0x40f8('0x70')]=_0x5a2a59[0x0];if(!_0x36df62[_0x40f8('0x58')]['UserId'])return;return db['User']['find']({'where':{'id':_0x36df62[_0x40f8('0x58')][_0x40f8('0x63')],'role':_0x40f8('0x62')},'attributes':['id',_0x40f8('0x39'),_0x40f8('0x71'),_0x40f8('0x72'),_0x40f8('0x73')],'raw':!![]});}return null;})[_0x40f8('0x34')](function(_0xd3e811){if(!_0xd3e811)return null;_0x3b7ee1[_0x40f8('0x27')][_0x40f8('0x62')]=_0xd3e811;return _0x3b7ee1;})[_0x40f8('0x34')](function(_0x359a5d){if(_0x359a5d){if(_0x36df62[_0x40f8('0x58')]['manual']){_0x3b7ee1[_0x40f8('0x27')][_0x40f8('0x74')]=util[_0x40f8('0x5f')]('SIP/%s',_0x36df62[_0x40f8('0x61')]['name']);_0x3b7ee1[_0x40f8('0x27')][_0x40f8('0x75')]=_0x3b7ee1[_0x40f8('0x75')];_0x3b7ee1['message']['event']=_0x40f8('0x5b');return respondWithRpcPromise(_0x40f8('0x76'),_0x40f8('0x76'),{'event':_0x40f8('0x77'),'message':_0x3b7ee1[_0x40f8('0x27')]},client9002)[_0x40f8('0x34')](function(){return _0x3b7ee1;});}return _0x3b7ee1;}return null;})['then'](respondWithResult(_0x49c5f6,null))[_0x40f8('0x29')](handleError(_0x49c5f6,null));};var interaction_log=require(_0x40f8('0x13'))('sms-interactions');exports[_0x40f8('0x31')]=function(_0x193bc7,_0x9f113b,_0x2d2826){var _0x58efc0={'agent':{},'channel':'sms'};if(_0x193bc7[_0x40f8('0x58')]['id']){delete _0x193bc7[_0x40f8('0x58')]['id'];}_0x193bc7['body'][_0x40f8('0x63')]=_0x193bc7[_0x40f8('0x58')][_0x40f8('0x63')]||_0x193bc7['user']['id'];_0x58efc0[_0x40f8('0x62')]['id']=_0x193bc7[_0x40f8('0x58')][_0x40f8('0x63')];return db[_0x40f8('0x3d')][_0x40f8('0x56')]({'where':{'id':_0x193bc7[_0x40f8('0x53')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x9f113b,null))[_0x40f8('0x34')](function(_0x43b329){if(_0x43b329){_0x58efc0['message']=_0x43b329[_0x40f8('0x64')]({'plain':!![]});return db['SmsInteraction'][_0x40f8('0x56')]({'where':{'id':_0x43b329[_0x40f8('0x66')]}});}return null;})[_0x40f8('0x34')](handleEntityNotFound(_0x9f113b,null))[_0x40f8('0x34')](function(_0x35d9fc){if(_0x35d9fc){_0x58efc0[_0x40f8('0x68')]=_0x35d9fc[_0x40f8('0x64')]({'plain':!![]});interaction_log[_0x40f8('0x21')](_0x40f8('0x78'),_0x193bc7['user']['id'],_0x193bc7['user'][_0x40f8('0x39')],_0x193bc7[_0x40f8('0x61')][_0x40f8('0x69')],_0x58efc0[_0x40f8('0x68')]['id'],_0x193bc7[_0x40f8('0x58')]?JSON[_0x40f8('0x25')](_0x193bc7[_0x40f8('0x58')]):'null');return respondWithRpcPromise(_0x40f8('0x79'),_0x40f8('0x7a'),_0x58efc0);}return null;})[_0x40f8('0x34')](function(_0x5cf437){var _0x26611a=_0x40f8('0x6b')+_0x5cf437['message'][_0x40f8('0x6c')];return db[_0x40f8('0x7b')]['query'](_0x26611a,{'type':db[_0x40f8('0x6d')][_0x40f8('0x6e')][_0x40f8('0x6f')],'raw':!![]})[_0x40f8('0x34')](function(_0x4301c3){return _0x4301c3;});})[_0x40f8('0x34')](function(_0xbc4e64){if(_0xbc4e64){_0x58efc0[_0x40f8('0x27')][_0x40f8('0x70')]=_0xbc4e64[0x0];if(!_0x193bc7['body'][_0x40f8('0x63')])return;return db['User'][_0x40f8('0x56')]({'where':{'id':_0x193bc7['body'][_0x40f8('0x63')],'role':_0x40f8('0x62')},'attributes':['id',_0x40f8('0x39'),'fullname',_0x40f8('0x72'),_0x40f8('0x73')],'raw':!![]});}return null;})['then'](function(_0x37098f){if(!_0x37098f)return null;_0x58efc0[_0x40f8('0x27')]['agent']=_0x37098f;return _0x58efc0;})[_0x40f8('0x34')](function(_0x8d0c12){if(_0x8d0c12){_0x8d0c12[_0x40f8('0x27')][_0x40f8('0x74')]=util[_0x40f8('0x5f')](_0x40f8('0x7c'),_0x193bc7[_0x40f8('0x61')][_0x40f8('0x39')]);_0x8d0c12[_0x40f8('0x27')]['channel']=_0x58efc0[_0x40f8('0x75')];_0x8d0c12[_0x40f8('0x27')][_0x40f8('0x7d')]='reject';respondWithRpcPromise(_0x40f8('0x76'),_0x40f8('0x76'),{'event':'rejectmessage','message':_0x8d0c12[_0x40f8('0x27')]},client9002);return _0x58efc0;}return null;})['then'](respondWithResult(_0x9f113b,null))[_0x40f8('0x29')](handleError(_0x9f113b,null));};exports[_0x40f8('0x36')]=function(_0x352069,_0x2ee536,_0x2a9438){if(_0x352069[_0x40f8('0x58')]['id']){delete _0x352069[_0x40f8('0x58')]['id'];}var _0x2f0ab4;return db['SmsMessage'][_0x40f8('0x56')]({'where':{'id':_0x352069[_0x40f8('0x53')]['id']}})[_0x40f8('0x34')](handleEntityNotFound(_0x2ee536,null))['then'](function(_0x75c110){if(_0x75c110){_0x2f0ab4=_0x75c110;return db['SmsAccount'][_0x40f8('0x56')]({'where':{'id':_0x75c110[_0x40f8('0x7e')]}});}})[_0x40f8('0x34')](handleEntityNotFound(_0x2ee536,null))[_0x40f8('0x34')](function(_0x1fa3f4){if(_0x1fa3f4){logger[_0x40f8('0x24')](_0x40f8('0x7f'),_0x40f8('0x36'),'received\x20delivery\x20report\x20from',_0x1fa3f4['type'],util[_0x40f8('0x80')](_0x352069[_0x40f8('0x58')],{'showHidden':![],'depth':null}));switch(_0x1fa3f4['type']){case _0x40f8('0x81'):if(_0x352069[_0x40f8('0x58')][_0x40f8('0x82')]&&_0x352069['body'][_0x40f8('0x82')]===_0x2f0ab4[_0x40f8('0x83')]){return _0x2f0ab4[_0x40f8('0x33')]({'read':!![]});}else{logger[_0x40f8('0x26')](_0x40f8('0x84'),_0x40f8('0x36'),'twilio',util[_0x40f8('0x80')](_0x352069[_0x40f8('0x58')],{'showHidden':![],'depth':null}));}break;case _0x40f8('0x85'):if(_0x352069['body'][_0x40f8('0x86')]&&_0x352069[_0x40f8('0x58')][_0x40f8('0x86')]===_0x2f0ab4[_0x40f8('0x83')]&&_['indexOf'](['sent',_0x40f8('0x87')],_0x352069[_0x40f8('0x58')][_0x40f8('0x88')])>=0x0){return _0x2f0ab4[_0x40f8('0x33')]({'read':!![]});}else{logger[_0x40f8('0x26')](_0x40f8('0x84'),_0x40f8('0x36'),_0x40f8('0x89'),util[_0x40f8('0x80')](_0x352069[_0x40f8('0x58')],{'showHidden':![],'depth':null}));}break;case _0x40f8('0x8a'):var _0x405126=_0x352069['body'][_0x40f8('0x8b')][0x0];if(_0x405126[_0x40f8('0x36')][_0x40f8('0x8c')]===_0x40f8('0x8d')){return _0x2f0ab4[_0x40f8('0x33')]({'read':!![]});}else{logger[_0x40f8('0x26')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0x40f8('0x36'),_0x40f8('0x8a'),util[_0x40f8('0x80')](_0x352069[_0x40f8('0x58')],{'showHidden':![],'depth':null}));}break;}return _0x2f0ab4;}})[_0x40f8('0x34')](respondWithResult(_0x2ee536,null))[_0x40f8('0x29')](handleError(_0x2ee536,null));};
\ No newline at end of file
+var _0xbc7a=['event','rejectmessage','SmsAccount','SmsAccountId','inspect','twilio','MessageSid','messageId','plivo','MessageUUID','indexOf','sent','delivered','Status','SmsAccount,\x20%s,\x20%s,\x20%s','plivio','infobip','results','groupName','DELIVERED','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','socket.io-emitter','register','client','http','then','SmsMessage,\x20%s,\x20%s','request\x20sent','SmsMessage,\x20%s,\x20%s,\x20%s','error','message','info','result','catch','sendStatus','end','offset','undefined','limit','count','status','apply','reject','save','update','stack','send','rawAttributes','fieldName','type','key','map','name','query','keys','filters','model','attributes','intersection','fields','length','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','SmsMessage','include','findAll','rows','show','params','create','body','find','destroy','describe','sms-interactions','sms','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','SmsInteraction','isNil','interaction','[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','Sequelize','QueryTypes','SELECT','contact','User','fullname','email','internal','interface','SIP/%s','channel','motionChannel','accept','EventManager','acceptmessage','SmsInteractionId','stringify','RejectMessage','rejectMessage'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xbc7a,0xa4));var _0xabc7=function(_0x59b6c1,_0x33258b){_0x59b6c1=_0x59b6c1-0x0;var _0x329560=_0xbc7a[_0x59b6c1];return _0x329560;};'use strict';var emlformat=require(_0xabc7('0x0'));var rimraf=require(_0xabc7('0x1'));var zipdir=require(_0xabc7('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xabc7('0x3'));var moment=require(_0xabc7('0x4'));var BPromise=require(_0xabc7('0x5'));var Mustache=require(_0xabc7('0x6'));var util=require(_0xabc7('0x7'));var path=require(_0xabc7('0x8'));var sox=require('sox');var csv=require(_0xabc7('0x9'));var ejs=require(_0xabc7('0xa'));var fs=require('fs');var fs_extra=require(_0xabc7('0xb'));var _=require(_0xabc7('0xc'));var squel=require(_0xabc7('0xd'));var crypto=require(_0xabc7('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xabc7('0xf'));var toCsv=require('to-csv');var querystring=require(_0xabc7('0x10'));var Papa=require(_0xabc7('0x11'));var Redis=require(_0xabc7('0x12'));var authService=require(_0xabc7('0x13'));var qs=require(_0xabc7('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xabc7('0x15'))('api');var utils=require(_0xabc7('0x16'));var config=require(_0xabc7('0x17'));var licenseUtil=require(_0xabc7('0x18'));var db=require('../../mysqldb')['db'];config[_0xabc7('0x19')]=_[_0xabc7('0x1a')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xabc7('0x1b'))(new Redis(config[_0xabc7('0x19')]));require('./smsMessage.socket')[_0xabc7('0x1c')](socket);var jayson=require('jayson/promise');var client=jayson[_0xabc7('0x1d')][_0xabc7('0x1e')]({'port':0x232c});var client9002=jayson[_0xabc7('0x1d')][_0xabc7('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x4b3575,_0x50027a,_0x42f77a,_0xa23fd){return new BPromise(function(_0x4216a2,_0x2d1e4e){var _0x5a184e=_0xa23fd||client;return _0x5a184e['request'](_0x4b3575,_0x42f77a)[_0xabc7('0x1f')](function(_0x181dd6){logger['info'](_0xabc7('0x20'),_0x50027a,_0xabc7('0x21'));logger['debug'](_0xabc7('0x22'),_0x50027a,_0xabc7('0x21'),JSON['stringify'](_0x181dd6));if(_0x181dd6[_0xabc7('0x23')]){if(_0x181dd6['error']['code']===0x1f4){logger['error'](_0xabc7('0x20'),_0x50027a,_0x181dd6['error'][_0xabc7('0x24')]);return _0x2d1e4e(_0x181dd6['error']['message']);}logger[_0xabc7('0x23')](_0xabc7('0x20'),_0x50027a,_0x181dd6[_0xabc7('0x23')]['message']);return _0x4216a2(_0x181dd6[_0xabc7('0x23')][_0xabc7('0x24')]);}else{logger[_0xabc7('0x25')](_0xabc7('0x20'),_0x50027a,_0xabc7('0x21'));_0x4216a2(_0x181dd6[_0xabc7('0x26')][_0xabc7('0x24')]);}})[_0xabc7('0x27')](function(_0x924f1b){logger['error'](_0xabc7('0x20'),_0x50027a,_0x924f1b);_0x2d1e4e(_0x924f1b);});});}function respondWithStatusCode(_0x2c66d2,_0x10bb9e){_0x10bb9e=_0x10bb9e||0xcc;return function(_0x5b5a59){if(_0x5b5a59){return _0x2c66d2[_0xabc7('0x28')](_0x10bb9e);}return _0x2c66d2['status'](_0x10bb9e)[_0xabc7('0x29')]();};}function respondWithResult(_0x2a0d86,_0x305cdb){_0x305cdb=_0x305cdb||0xc8;return function(_0x429144){if(_0x429144){return _0x2a0d86['status'](_0x305cdb)['json'](_0x429144);}};}function respondWithFilteredResult(_0x3b0bdc,_0x5dd2a3){return function(_0x5a4c1d){if(_0x5a4c1d){var _0x1fdbea=typeof _0x5dd2a3[_0xabc7('0x2a')]===_0xabc7('0x2b')&&typeof _0x5dd2a3[_0xabc7('0x2c')]===_0xabc7('0x2b');var _0x22d34e=_0x5a4c1d[_0xabc7('0x2d')];var _0x43b4a9=_0x1fdbea?0x0:_0x5dd2a3[_0xabc7('0x2a')];var _0xdcb9aa=_0x1fdbea?_0x5a4c1d['count']:_0x5dd2a3['offset']+_0x5dd2a3[_0xabc7('0x2c')];var _0x249dc4;if(_0xdcb9aa>=_0x22d34e){_0xdcb9aa=_0x22d34e;_0x249dc4=0xc8;}else{_0x249dc4=0xce;}_0x3b0bdc[_0xabc7('0x2e')](_0x249dc4);return _0x3b0bdc['set']('Content-Range',_0x43b4a9+'-'+_0xdcb9aa+'/'+_0x22d34e)['json'](_0x5a4c1d);}return null;};}function patchUpdates(_0x3976d2){return function(_0x233bcb){try{jsonpatch[_0xabc7('0x2f')](_0x233bcb,_0x3976d2,!![]);}catch(_0x212648){return BPromise[_0xabc7('0x30')](_0x212648);}return _0x233bcb[_0xabc7('0x31')]();};}function saveUpdates(_0x3572f6,_0x1810ec){return function(_0x17e125){if(_0x17e125){return _0x17e125[_0xabc7('0x32')](_0x3572f6)[_0xabc7('0x1f')](function(_0xf77b21){return _0xf77b21;});}return null;};}function removeEntity(_0x1426cd,_0x219eb7){return function(_0x67dbd2){if(_0x67dbd2){return _0x67dbd2['destroy']()[_0xabc7('0x1f')](function(){_0x1426cd[_0xabc7('0x2e')](0xcc)[_0xabc7('0x29')]();});}};}function handleEntityNotFound(_0xe68b4e,_0x33c64e){return function(_0xe55703){if(!_0xe55703){_0xe68b4e['sendStatus'](0x194);}return _0xe55703;};}function handleError(_0x1a46d9,_0x271779){_0x271779=_0x271779||0x1f4;return function(_0x468f37){logger[_0xabc7('0x23')](_0x468f37[_0xabc7('0x33')]);if(_0x468f37['name']){delete _0x468f37['name'];}_0x1a46d9[_0xabc7('0x2e')](_0x271779)[_0xabc7('0x34')](_0x468f37);};}exports['index']=function(_0x1f3c8a,_0x389c39){var _0x4112b3={},_0x286b6f={},_0xbbf5ad={'count':0x0,'rows':[]};var _0xe798fa=_['map'](db['SmsMessage'][_0xabc7('0x35')],function(_0x3110ab){return{'name':_0x3110ab[_0xabc7('0x36')],'type':_0x3110ab[_0xabc7('0x37')][_0xabc7('0x38')]};});_0x286b6f['model']=_[_0xabc7('0x39')](_0xe798fa,_0xabc7('0x3a'));_0x286b6f[_0xabc7('0x3b')]=_[_0xabc7('0x3c')](_0x1f3c8a['query']);_0x286b6f[_0xabc7('0x3d')]=_['intersection'](_0x286b6f[_0xabc7('0x3e')],_0x286b6f[_0xabc7('0x3b')]);_0x4112b3[_0xabc7('0x3f')]=_[_0xabc7('0x40')](_0x286b6f['model'],qs['fields'](_0x1f3c8a[_0xabc7('0x3b')][_0xabc7('0x41')]));_0x4112b3['attributes']=_0x4112b3[_0xabc7('0x3f')][_0xabc7('0x42')]?_0x4112b3[_0xabc7('0x3f')]:_0x286b6f[_0xabc7('0x3e')];if(!_0x1f3c8a['query']['hasOwnProperty'](_0xabc7('0x43'))){_0x4112b3[_0xabc7('0x2c')]=qs['limit'](_0x1f3c8a[_0xabc7('0x3b')][_0xabc7('0x2c')]);_0x4112b3[_0xabc7('0x2a')]=qs[_0xabc7('0x2a')](_0x1f3c8a[_0xabc7('0x3b')]['offset']);}_0x4112b3['order']=qs[_0xabc7('0x44')](_0x1f3c8a[_0xabc7('0x3b')]['sort']);_0x4112b3[_0xabc7('0x45')]=qs[_0xabc7('0x3d')](_[_0xabc7('0x46')](_0x1f3c8a[_0xabc7('0x3b')],_0x286b6f['filters']),_0xe798fa);if(_0x1f3c8a['query'][_0xabc7('0x47')]){_0x4112b3[_0xabc7('0x45')]=_[_0xabc7('0x48')](_0x4112b3['where'],{'$or':_[_0xabc7('0x39')](_0xe798fa,function(_0x41cca1){if(_0x41cca1[_0xabc7('0x37')]!==_0xabc7('0x49')){var _0x5be7af={};_0x5be7af[_0x41cca1[_0xabc7('0x3a')]]={'$like':'%'+_0x1f3c8a[_0xabc7('0x3b')][_0xabc7('0x47')]+'%'};return _0x5be7af;}})});}_0x4112b3=_[_0xabc7('0x48')]({},_0x4112b3,_0x1f3c8a[_0xabc7('0x4a')]);var _0x227f9c={'where':_0x4112b3[_0xabc7('0x45')]};return db[_0xabc7('0x4b')][_0xabc7('0x2d')](_0x227f9c)[_0xabc7('0x1f')](function(_0x20112f){_0xbbf5ad[_0xabc7('0x2d')]=_0x20112f;if(_0x1f3c8a[_0xabc7('0x3b')]['includeAll']){_0x4112b3[_0xabc7('0x4c')]=[{'all':!![]}];}return db[_0xabc7('0x4b')][_0xabc7('0x4d')](_0x4112b3);})[_0xabc7('0x1f')](function(_0x20a31f){_0xbbf5ad[_0xabc7('0x4e')]=_0x20a31f;return _0xbbf5ad;})[_0xabc7('0x1f')](respondWithFilteredResult(_0x389c39,_0x4112b3))['catch'](handleError(_0x389c39,null));};exports[_0xabc7('0x4f')]=function(_0xfab427,_0x2a4d89){var _0x559b65={'raw':!![],'where':{'id':_0xfab427[_0xabc7('0x50')]['id']}},_0x464a68={};_0x464a68['model']=_[_0xabc7('0x3c')](db[_0xabc7('0x4b')][_0xabc7('0x35')]);_0x464a68[_0xabc7('0x3b')]=_[_0xabc7('0x3c')](_0xfab427[_0xabc7('0x3b')]);_0x464a68['filters']=_['intersection'](_0x464a68[_0xabc7('0x3e')],_0x464a68['query']);_0x559b65[_0xabc7('0x3f')]=_[_0xabc7('0x40')](_0x464a68[_0xabc7('0x3e')],qs[_0xabc7('0x41')](_0xfab427['query'][_0xabc7('0x41')]));_0x559b65[_0xabc7('0x3f')]=_0x559b65['attributes']['length']?_0x559b65['attributes']:_0x464a68[_0xabc7('0x3e')];if(_0xfab427[_0xabc7('0x3b')]['includeAll']){_0x559b65[_0xabc7('0x4c')]=[{'all':!![]}];}_0x559b65=_[_0xabc7('0x48')]({},_0x559b65,_0xfab427['options']);return db[_0xabc7('0x4b')]['find'](_0x559b65)[_0xabc7('0x1f')](handleEntityNotFound(_0x2a4d89,null))[_0xabc7('0x1f')](respondWithResult(_0x2a4d89,null))[_0xabc7('0x27')](handleError(_0x2a4d89,null));};exports[_0xabc7('0x51')]=function(_0x10280f,_0x3b58b6){return db[_0xabc7('0x4b')][_0xabc7('0x51')](_0x10280f[_0xabc7('0x52')],{})['then'](respondWithResult(_0x3b58b6,0xc9))[_0xabc7('0x27')](handleError(_0x3b58b6,null));};exports['update']=function(_0x4af394,_0x553418){if(_0x4af394[_0xabc7('0x52')]['id']){delete _0x4af394[_0xabc7('0x52')]['id'];}return db[_0xabc7('0x4b')][_0xabc7('0x53')]({'where':{'id':_0x4af394['params']['id']}})[_0xabc7('0x1f')](handleEntityNotFound(_0x553418,null))['then'](saveUpdates(_0x4af394[_0xabc7('0x52')],null))['then'](respondWithResult(_0x553418,null))[_0xabc7('0x27')](handleError(_0x553418,null));};exports[_0xabc7('0x54')]=function(_0x4d266b,_0x314740){return db[_0xabc7('0x4b')][_0xabc7('0x53')]({'where':{'id':_0x4d266b['params']['id']}})[_0xabc7('0x1f')](handleEntityNotFound(_0x314740,null))['then'](removeEntity(_0x314740,null))['catch'](handleError(_0x314740,null));};exports[_0xabc7('0x55')]=function(_0x3fcf5a,_0x3ef95f){return db['SmsMessage'][_0xabc7('0x55')]()[_0xabc7('0x1f')](respondWithResult(_0x3ef95f,null))[_0xabc7('0x27')](handleError(_0x3ef95f,null));};var interaction_log=require('../../config/logger')(_0xabc7('0x56'));exports['accept']=function(_0x44a86a,_0x430279,_0x2f963a){var _0x3615af={'agent':{},'channel':_0xabc7('0x57')};if(_0x44a86a[_0xabc7('0x52')]['id']){delete _0x44a86a['body']['id'];}_0x44a86a[_0xabc7('0x52')]['read']=!![];_0x44a86a['body'][_0xabc7('0x58')]=moment()[_0xabc7('0x59')](_0xabc7('0x5a'));_0x44a86a[_0xabc7('0x52')][_0xabc7('0x5b')]=_0x44a86a[_0xabc7('0x52')]['UserId']||_0x44a86a[_0xabc7('0x5c')]['id'];_0x3615af[_0xabc7('0x5d')]['id']=_0x44a86a[_0xabc7('0x52')][_0xabc7('0x5b')];return db[_0xabc7('0x4b')][_0xabc7('0x53')]({'where':{'id':_0x44a86a[_0xabc7('0x50')]['id'],'UserId':null}})[_0xabc7('0x1f')](handleEntityNotFound(_0x430279,null))[_0xabc7('0x1f')](saveUpdates(_0x44a86a[_0xabc7('0x52')],null))[_0xabc7('0x1f')](function(_0x345f84){if(_0x345f84){_0x3615af[_0xabc7('0x24')]=_0x345f84[_0xabc7('0x5e')]({'plain':!![]});return db[_0xabc7('0x5f')]['find']({'where':{'id':_0x345f84['SmsInteractionId']}});}return null;})[_0xabc7('0x1f')](handleEntityNotFound(_0x430279,null))['then'](function(_0xe52f1c){if(_0xe52f1c){return _0xe52f1c['update']({'UserId':_0x44a86a[_0xabc7('0x52')][_0xabc7('0x5b')],'read1stAt':_[_0xabc7('0x60')](_0xe52f1c['read1stAt'])?moment()[_0xabc7('0x59')](_0xabc7('0x5a')):undefined});}return null;})[_0xabc7('0x1f')](function(_0x5be9a6){if(_0x5be9a6){_0x3615af[_0xabc7('0x61')]=_0x5be9a6[_0xabc7('0x5e')]({'plain':!![]});interaction_log['info'](_0xabc7('0x62'),_0x44a86a[_0xabc7('0x5c')]['id'],_0x44a86a[_0xabc7('0x5c')][_0xabc7('0x3a')],_0x44a86a[_0xabc7('0x5c')][_0xabc7('0x63')],_0x3615af[_0xabc7('0x61')]['id'],_0x44a86a[_0xabc7('0x52')]?JSON['stringify'](_0x44a86a[_0xabc7('0x52')]):_0xabc7('0x64'));return respondWithRpcPromise('AcceptMessage',_0xabc7('0x65'),_0x3615af);}return null;})[_0xabc7('0x1f')](function(_0x38c3ab){var _0x31338c=_0xabc7('0x66')+_0x38c3ab[_0xabc7('0x24')][_0xabc7('0x67')];return db[_0xabc7('0x68')][_0xabc7('0x3b')](_0x31338c,{'type':db[_0xabc7('0x69')][_0xabc7('0x6a')][_0xabc7('0x6b')],'raw':!![]})[_0xabc7('0x1f')](function(_0x51b26f){return _0x51b26f;});})[_0xabc7('0x1f')](function(_0x5ef6d6){if(_0x5ef6d6){_0x3615af[_0xabc7('0x24')][_0xabc7('0x6c')]=_0x5ef6d6[0x0];if(!_0x44a86a[_0xabc7('0x52')][_0xabc7('0x5b')])return;return db[_0xabc7('0x6d')][_0xabc7('0x53')]({'where':{'id':_0x44a86a[_0xabc7('0x52')][_0xabc7('0x5b')],'role':'agent'},'attributes':['id',_0xabc7('0x3a'),_0xabc7('0x6e'),_0xabc7('0x6f'),_0xabc7('0x70')],'raw':!![]});}return null;})[_0xabc7('0x1f')](function(_0x457be5){if(!_0x457be5)return null;_0x3615af[_0xabc7('0x24')]['agent']=_0x457be5;return _0x3615af;})[_0xabc7('0x1f')](function(_0x23e80a){if(_0x23e80a){if(_0x44a86a[_0xabc7('0x52')]['manual']){_0x3615af['message'][_0xabc7('0x71')]=util[_0xabc7('0x59')](_0xabc7('0x72'),_0x44a86a[_0xabc7('0x5c')][_0xabc7('0x3a')]);_0x3615af[_0xabc7('0x24')][_0xabc7('0x73')]=_0x3615af[_0xabc7('0x73')];_0x3615af[_0xabc7('0x24')][_0xabc7('0x74')]=_0x3615af[_0xabc7('0x73')];_0x3615af[_0xabc7('0x24')]['event']=_0xabc7('0x75');return respondWithRpcPromise(_0xabc7('0x76'),_0xabc7('0x76'),{'event':_0xabc7('0x77'),'message':_0x3615af[_0xabc7('0x24')]},client9002)[_0xabc7('0x1f')](function(){return _0x3615af;});}return _0x3615af;}return null;})['then'](respondWithResult(_0x430279,null))[_0xabc7('0x27')](handleError(_0x430279,null));};var interaction_log=require('../../config/logger')(_0xabc7('0x56'));exports[_0xabc7('0x30')]=function(_0x295582,_0x323a77,_0x284f1b){var _0x8ae4c6={'agent':{},'channel':_0xabc7('0x57')};if(_0x295582[_0xabc7('0x52')]['id']){delete _0x295582['body']['id'];}_0x295582[_0xabc7('0x52')][_0xabc7('0x5b')]=_0x295582[_0xabc7('0x52')][_0xabc7('0x5b')]||_0x295582[_0xabc7('0x5c')]['id'];_0x8ae4c6[_0xabc7('0x5d')]['id']=_0x295582['body'][_0xabc7('0x5b')];return db['SmsMessage']['find']({'where':{'id':_0x295582[_0xabc7('0x50')]['id'],'UserId':null}})[_0xabc7('0x1f')](handleEntityNotFound(_0x323a77,null))[_0xabc7('0x1f')](function(_0x49f00d){if(_0x49f00d){_0x8ae4c6[_0xabc7('0x24')]=_0x49f00d[_0xabc7('0x5e')]({'plain':!![]});return db[_0xabc7('0x5f')][_0xabc7('0x53')]({'where':{'id':_0x49f00d[_0xabc7('0x78')]}});}return null;})[_0xabc7('0x1f')](handleEntityNotFound(_0x323a77,null))[_0xabc7('0x1f')](function(_0xc8a3d8){if(_0xc8a3d8){_0x8ae4c6[_0xabc7('0x61')]=_0xc8a3d8[_0xabc7('0x5e')]({'plain':!![]});interaction_log[_0xabc7('0x25')]('[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x295582[_0xabc7('0x5c')]['id'],_0x295582[_0xabc7('0x5c')]['name'],_0x295582[_0xabc7('0x5c')][_0xabc7('0x63')],_0x8ae4c6[_0xabc7('0x61')]['id'],_0x295582['body']?JSON[_0xabc7('0x79')](_0x295582['body']):'null');return respondWithRpcPromise(_0xabc7('0x7a'),_0xabc7('0x7b'),_0x8ae4c6);}return null;})[_0xabc7('0x1f')](function(_0x4785a4){var _0x3a0587=_0xabc7('0x66')+_0x4785a4[_0xabc7('0x24')][_0xabc7('0x67')];return db[_0xabc7('0x68')][_0xabc7('0x3b')](_0x3a0587,{'type':db[_0xabc7('0x69')][_0xabc7('0x6a')]['SELECT'],'raw':!![]})['then'](function(_0x26a799){return _0x26a799;});})[_0xabc7('0x1f')](function(_0x2e6d01){if(_0x2e6d01){_0x8ae4c6[_0xabc7('0x24')][_0xabc7('0x6c')]=_0x2e6d01[0x0];if(!_0x295582[_0xabc7('0x52')][_0xabc7('0x5b')])return;return db[_0xabc7('0x6d')][_0xabc7('0x53')]({'where':{'id':_0x295582[_0xabc7('0x52')][_0xabc7('0x5b')],'role':_0xabc7('0x5d')},'attributes':['id',_0xabc7('0x3a'),'fullname',_0xabc7('0x6f'),_0xabc7('0x70')],'raw':!![]});}return null;})[_0xabc7('0x1f')](function(_0x46f801){if(!_0x46f801)return null;_0x8ae4c6[_0xabc7('0x24')][_0xabc7('0x5d')]=_0x46f801;return _0x8ae4c6;})[_0xabc7('0x1f')](function(_0x4cf193){if(_0x4cf193){_0x4cf193['message']['interface']=util['format'](_0xabc7('0x72'),_0x295582[_0xabc7('0x5c')][_0xabc7('0x3a')]);_0x4cf193['message'][_0xabc7('0x73')]=_0x8ae4c6[_0xabc7('0x73')];_0x4cf193['message'][_0xabc7('0x74')]=_0x8ae4c6[_0xabc7('0x73')];_0x4cf193[_0xabc7('0x24')][_0xabc7('0x7c')]='reject';respondWithRpcPromise(_0xabc7('0x76'),'EventManager',{'event':_0xabc7('0x7d'),'message':_0x4cf193[_0xabc7('0x24')]},client9002);return _0x8ae4c6;}return null;})[_0xabc7('0x1f')](respondWithResult(_0x323a77,null))[_0xabc7('0x27')](handleError(_0x323a77,null));};exports[_0xabc7('0x2e')]=function(_0x145242,_0x4dfeea,_0x48e977){if(_0x145242['body']['id']){delete _0x145242[_0xabc7('0x52')]['id'];}var _0x4c1d32;return db[_0xabc7('0x4b')][_0xabc7('0x53')]({'where':{'id':_0x145242[_0xabc7('0x50')]['id']}})['then'](handleEntityNotFound(_0x4dfeea,null))[_0xabc7('0x1f')](function(_0x5b4a0c){if(_0x5b4a0c){_0x4c1d32=_0x5b4a0c;return db[_0xabc7('0x7e')]['find']({'where':{'id':_0x5b4a0c[_0xabc7('0x7f')]}});}})[_0xabc7('0x1f')](handleEntityNotFound(_0x4dfeea,null))[_0xabc7('0x1f')](function(_0x37803d){if(_0x37803d){logger['debug'](_0xabc7('0x22'),_0xabc7('0x2e'),'received\x20delivery\x20report\x20from',_0x37803d[_0xabc7('0x37')],util[_0xabc7('0x80')](_0x145242[_0xabc7('0x52')],{'showHidden':![],'depth':null}));switch(_0x37803d[_0xabc7('0x37')]){case _0xabc7('0x81'):if(_0x145242[_0xabc7('0x52')]['MessageSid']&&_0x145242['body'][_0xabc7('0x82')]===_0x4c1d32[_0xabc7('0x83')]){return _0x4c1d32[_0xabc7('0x32')]({'read':!![]});}else{logger[_0xabc7('0x23')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0xabc7('0x2e'),_0xabc7('0x81'),util[_0xabc7('0x80')](_0x145242[_0xabc7('0x52')],{'showHidden':![],'depth':null}));}break;case _0xabc7('0x84'):if(_0x145242['body'][_0xabc7('0x85')]&&_0x145242[_0xabc7('0x52')]['MessageUUID']===_0x4c1d32['messageId']&&_[_0xabc7('0x86')]([_0xabc7('0x87'),_0xabc7('0x88')],_0x145242['body'][_0xabc7('0x89')])>=0x0){return _0x4c1d32[_0xabc7('0x32')]({'read':!![]});}else{logger[_0xabc7('0x23')](_0xabc7('0x8a'),_0xabc7('0x2e'),_0xabc7('0x8b'),util[_0xabc7('0x80')](_0x145242[_0xabc7('0x52')],{'showHidden':![],'depth':null}));}break;case _0xabc7('0x8c'):var _0x2a8c63=_0x145242[_0xabc7('0x52')][_0xabc7('0x8d')][0x0];if(_0x2a8c63[_0xabc7('0x2e')][_0xabc7('0x8e')]===_0xabc7('0x8f')){return _0x4c1d32[_0xabc7('0x32')]({'read':!![]});}else{logger[_0xabc7('0x23')](_0xabc7('0x8a'),_0xabc7('0x2e'),_0xabc7('0x8c'),util[_0xabc7('0x80')](_0x145242[_0xabc7('0x52')],{'showHidden':![],'depth':null}));}break;}return _0x4c1d32;}})['then'](respondWithResult(_0x4dfeea,null))[_0xabc7('0x27')](handleError(_0x4dfeea,null));};
\ No newline at end of file