Built motion from commit 7158bc59.|2.5.42
[motion2.git] / server / api / smsMessage / smsMessage.controller.js
index 527d118..40cf2e9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xaa64=['end','json','offset','undefined','count','limit','set','Content-Range','reject','save','update','then','destroy','name','send','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','includeAll','include','SmsMessage','findAll','rows','show','params','options','catch','create','body','find','describe','../../config/logger','accept','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','SmsInteractionId','isNil','format','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','sequelize','Sequelize','SELECT','contact','fullname','email','internal','manual','SIP/%s','channel','motionChannel','event','EventManager','acceptmessage','sms','RejectMessage','rejectMessage','ContactId','QueryTypes','User','interface','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','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./smsMessage.socket','client','http','request','info','SmsMessage,\x20%s,\x20%s','request\x20sent','debug','SmsMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','result','sendStatus','status'];(function(_0x35908d,_0x24c109){var _0x58492f=function(_0x573f08){while(--_0x573f08){_0x35908d['push'](_0x35908d['shift']());}};_0x58492f(++_0x24c109);}(_0xaa64,0xf7));var _0x4aa6=function(_0x1fafa5,_0x1aa281){_0x1fafa5=_0x1fafa5-0x0;var _0xcf08c9=_0xaa64[_0x1fafa5];return _0xcf08c9;};'use strict';var emlformat=require(_0x4aa6('0x0'));var rimraf=require(_0x4aa6('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x4aa6('0x2'));var rp=require('request-promise');var moment=require(_0x4aa6('0x3'));var BPromise=require(_0x4aa6('0x4'));var Mustache=require(_0x4aa6('0x5'));var util=require('util');var path=require(_0x4aa6('0x6'));var sox=require(_0x4aa6('0x7'));var csv=require(_0x4aa6('0x8'));var ejs=require(_0x4aa6('0x9'));var fs=require('fs');var fs_extra=require(_0x4aa6('0xa'));var _=require(_0x4aa6('0xb'));var squel=require(_0x4aa6('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x4aa6('0xd'));var toCsv=require(_0x4aa6('0x8'));var querystring=require('querystring');var Papa=require(_0x4aa6('0xe'));var Redis=require('ioredis');var authService=require(_0x4aa6('0xf'));var qs=require(_0x4aa6('0x10'));var as=require(_0x4aa6('0x11'));var hardwareService=require(_0x4aa6('0x12'));var logger=require('../../config/logger')(_0x4aa6('0x13'));var utils=require(_0x4aa6('0x14'));var config=require(_0x4aa6('0x15'));var licenseUtil=require(_0x4aa6('0x16'));var db=require(_0x4aa6('0x17'))['db'];config[_0x4aa6('0x18')]=_[_0x4aa6('0x19')](config[_0x4aa6('0x18')],{'host':_0x4aa6('0x1a'),'port':0x18eb});var socket=require(_0x4aa6('0x1b'))(new Redis(config['redis']));require(_0x4aa6('0x1c'))['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0x4aa6('0x1d')][_0x4aa6('0x1e')]({'port':0x232c});var client9002=jayson[_0x4aa6('0x1d')][_0x4aa6('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x375c09,_0x238f10,_0x3e234f,_0x2c5c66){return new BPromise(function(_0x530ed0,_0x138d55){var _0x5458ad=_0x2c5c66||client;return _0x5458ad[_0x4aa6('0x1f')](_0x375c09,_0x3e234f)['then'](function(_0x54a6d8){logger[_0x4aa6('0x20')](_0x4aa6('0x21'),_0x238f10,_0x4aa6('0x22'));logger[_0x4aa6('0x23')](_0x4aa6('0x24'),_0x238f10,_0x4aa6('0x22'),JSON[_0x4aa6('0x25')](_0x54a6d8));if(_0x54a6d8[_0x4aa6('0x26')]){if(_0x54a6d8[_0x4aa6('0x26')]['code']===0x1f4){logger[_0x4aa6('0x26')](_0x4aa6('0x21'),_0x238f10,_0x54a6d8[_0x4aa6('0x26')][_0x4aa6('0x27')]);return _0x138d55(_0x54a6d8[_0x4aa6('0x26')][_0x4aa6('0x27')]);}logger['error'](_0x4aa6('0x21'),_0x238f10,_0x54a6d8[_0x4aa6('0x26')][_0x4aa6('0x27')]);return _0x530ed0(_0x54a6d8[_0x4aa6('0x26')][_0x4aa6('0x27')]);}else{logger[_0x4aa6('0x20')]('SmsMessage,\x20%s,\x20%s',_0x238f10,_0x4aa6('0x22'));_0x530ed0(_0x54a6d8[_0x4aa6('0x28')]['message']);}})['catch'](function(_0x347856){logger[_0x4aa6('0x26')](_0x4aa6('0x21'),_0x238f10,_0x347856);_0x138d55(_0x347856);});});}function respondWithStatusCode(_0x3425df,_0x2001ce){_0x2001ce=_0x2001ce||0xcc;return function(_0x5e53a7){if(_0x5e53a7){return _0x3425df[_0x4aa6('0x29')](_0x2001ce);}return _0x3425df[_0x4aa6('0x2a')](_0x2001ce)[_0x4aa6('0x2b')]();};}function respondWithResult(_0x3bd7a8,_0x45a9e3){_0x45a9e3=_0x45a9e3||0xc8;return function(_0x256342){if(_0x256342){return _0x3bd7a8['status'](_0x45a9e3)[_0x4aa6('0x2c')](_0x256342);}};}function respondWithFilteredResult(_0x41bdc8,_0x5bc756){return function(_0x149c9a){if(_0x149c9a){var _0x121b97=typeof _0x5bc756[_0x4aa6('0x2d')]===_0x4aa6('0x2e')&&typeof _0x5bc756['limit']===_0x4aa6('0x2e');var _0x625df8=_0x149c9a[_0x4aa6('0x2f')];var _0x52b038=_0x121b97?0x0:_0x5bc756[_0x4aa6('0x2d')];var _0x29f31a=_0x121b97?_0x149c9a[_0x4aa6('0x2f')]:_0x5bc756['offset']+_0x5bc756[_0x4aa6('0x30')];var _0x2af33f;if(_0x29f31a>=_0x625df8){_0x29f31a=_0x625df8;_0x2af33f=0xc8;}else{_0x2af33f=0xce;}_0x41bdc8['status'](_0x2af33f);return _0x41bdc8[_0x4aa6('0x31')](_0x4aa6('0x32'),_0x52b038+'-'+_0x29f31a+'/'+_0x625df8)[_0x4aa6('0x2c')](_0x149c9a);}return null;};}function patchUpdates(_0x108903){return function(_0x1d71e5){try{jsonpatch['apply'](_0x1d71e5,_0x108903,!![]);}catch(_0x5b7ecc){return BPromise[_0x4aa6('0x33')](_0x5b7ecc);}return _0x1d71e5[_0x4aa6('0x34')]();};}function saveUpdates(_0x35006c,_0x5ec513){return function(_0x55e819){if(_0x55e819){return _0x55e819[_0x4aa6('0x35')](_0x35006c)[_0x4aa6('0x36')](function(_0x3efc36){return _0x3efc36;});}return null;};}function removeEntity(_0x19f5a5,_0xa463ae){return function(_0xbe8812){if(_0xbe8812){return _0xbe8812[_0x4aa6('0x37')]()[_0x4aa6('0x36')](function(){_0x19f5a5['status'](0xcc)[_0x4aa6('0x2b')]();});}};}function handleEntityNotFound(_0xec8944,_0x2ae741){return function(_0x40c289){if(!_0x40c289){_0xec8944[_0x4aa6('0x29')](0x194);}return _0x40c289;};}function handleError(_0xd3e41d,_0x4ab55d){_0x4ab55d=_0x4ab55d||0x1f4;return function(_0x223616){logger[_0x4aa6('0x26')](_0x223616['stack']);if(_0x223616[_0x4aa6('0x38')]){delete _0x223616[_0x4aa6('0x38')];}_0xd3e41d[_0x4aa6('0x2a')](_0x4ab55d)[_0x4aa6('0x39')](_0x223616);};}exports['index']=function(_0x4d03b1,_0x1126c4){var _0x2ad1bd={},_0x306bc1={},_0x5a74e8={'count':0x0,'rows':[]};var _0x2c4efd=_[_0x4aa6('0x3a')](db['SmsMessage'][_0x4aa6('0x3b')],function(_0x394319){return{'name':_0x394319[_0x4aa6('0x3c')],'type':_0x394319[_0x4aa6('0x3d')][_0x4aa6('0x3e')]};});_0x306bc1[_0x4aa6('0x3f')]=_['map'](_0x2c4efd,'name');_0x306bc1[_0x4aa6('0x40')]=_[_0x4aa6('0x41')](_0x4d03b1[_0x4aa6('0x40')]);_0x306bc1[_0x4aa6('0x42')]=_[_0x4aa6('0x43')](_0x306bc1['model'],_0x306bc1[_0x4aa6('0x40')]);_0x2ad1bd[_0x4aa6('0x44')]=_['intersection'](_0x306bc1[_0x4aa6('0x3f')],qs[_0x4aa6('0x45')](_0x4d03b1[_0x4aa6('0x40')][_0x4aa6('0x45')]));_0x2ad1bd[_0x4aa6('0x44')]=_0x2ad1bd['attributes'][_0x4aa6('0x46')]?_0x2ad1bd[_0x4aa6('0x44')]:_0x306bc1['model'];if(!_0x4d03b1[_0x4aa6('0x40')][_0x4aa6('0x47')]('nolimit')){_0x2ad1bd[_0x4aa6('0x30')]=qs[_0x4aa6('0x30')](_0x4d03b1['query'][_0x4aa6('0x30')]);_0x2ad1bd[_0x4aa6('0x2d')]=qs[_0x4aa6('0x2d')](_0x4d03b1[_0x4aa6('0x40')][_0x4aa6('0x2d')]);}_0x2ad1bd[_0x4aa6('0x48')]=qs[_0x4aa6('0x49')](_0x4d03b1['query'][_0x4aa6('0x49')]);_0x2ad1bd[_0x4aa6('0x4a')]=qs[_0x4aa6('0x42')](_[_0x4aa6('0x4b')](_0x4d03b1[_0x4aa6('0x40')],_0x306bc1[_0x4aa6('0x42')]),_0x2c4efd);if(_0x4d03b1[_0x4aa6('0x40')][_0x4aa6('0x4c')]){_0x2ad1bd['where']=_[_0x4aa6('0x4d')](_0x2ad1bd['where'],{'$or':_[_0x4aa6('0x3a')](_0x2c4efd,function(_0x2b1b48){if(_0x2b1b48[_0x4aa6('0x3d')]!=='VIRTUAL'){var _0x1c6731={};_0x1c6731[_0x2b1b48['name']]={'$like':'%'+_0x4d03b1['query'][_0x4aa6('0x4c')]+'%'};return _0x1c6731;}})});}_0x2ad1bd=_[_0x4aa6('0x4d')]({},_0x2ad1bd,_0x4d03b1['options']);var _0x1a92d4={'where':_0x2ad1bd[_0x4aa6('0x4a')]};return db['SmsMessage'][_0x4aa6('0x2f')](_0x1a92d4)['then'](function(_0x54b25c){_0x5a74e8[_0x4aa6('0x2f')]=_0x54b25c;if(_0x4d03b1['query'][_0x4aa6('0x4e')]){_0x2ad1bd[_0x4aa6('0x4f')]=[{'all':!![]}];}return db[_0x4aa6('0x50')][_0x4aa6('0x51')](_0x2ad1bd);})[_0x4aa6('0x36')](function(_0x8c5ada){_0x5a74e8[_0x4aa6('0x52')]=_0x8c5ada;return _0x5a74e8;})['then'](respondWithFilteredResult(_0x1126c4,_0x2ad1bd))['catch'](handleError(_0x1126c4,null));};exports[_0x4aa6('0x53')]=function(_0x58344c,_0x2f3ca6){var _0x4f23e0={'raw':!![],'where':{'id':_0x58344c[_0x4aa6('0x54')]['id']}},_0x193d48={};_0x193d48[_0x4aa6('0x3f')]=_[_0x4aa6('0x41')](db['SmsMessage']['rawAttributes']);_0x193d48[_0x4aa6('0x40')]=_[_0x4aa6('0x41')](_0x58344c[_0x4aa6('0x40')]);_0x193d48[_0x4aa6('0x42')]=_['intersection'](_0x193d48[_0x4aa6('0x3f')],_0x193d48[_0x4aa6('0x40')]);_0x4f23e0['attributes']=_[_0x4aa6('0x43')](_0x193d48['model'],qs[_0x4aa6('0x45')](_0x58344c[_0x4aa6('0x40')][_0x4aa6('0x45')]));_0x4f23e0[_0x4aa6('0x44')]=_0x4f23e0['attributes'][_0x4aa6('0x46')]?_0x4f23e0[_0x4aa6('0x44')]:_0x193d48[_0x4aa6('0x3f')];if(_0x58344c['query']['includeAll']){_0x4f23e0[_0x4aa6('0x4f')]=[{'all':!![]}];}_0x4f23e0=_[_0x4aa6('0x4d')]({},_0x4f23e0,_0x58344c[_0x4aa6('0x55')]);return db[_0x4aa6('0x50')]['find'](_0x4f23e0)[_0x4aa6('0x36')](handleEntityNotFound(_0x2f3ca6,null))[_0x4aa6('0x36')](respondWithResult(_0x2f3ca6,null))[_0x4aa6('0x56')](handleError(_0x2f3ca6,null));};exports[_0x4aa6('0x57')]=function(_0x5fd3ef,_0x2b0200){return db[_0x4aa6('0x50')]['create'](_0x5fd3ef[_0x4aa6('0x58')],{})['then'](respondWithResult(_0x2b0200,0xc9))['catch'](handleError(_0x2b0200,null));};exports['update']=function(_0xbc3e29,_0xc6d885){if(_0xbc3e29[_0x4aa6('0x58')]['id']){delete _0xbc3e29['body']['id'];}return db[_0x4aa6('0x50')][_0x4aa6('0x59')]({'where':{'id':_0xbc3e29[_0x4aa6('0x54')]['id']}})['then'](handleEntityNotFound(_0xc6d885,null))[_0x4aa6('0x36')](saveUpdates(_0xbc3e29[_0x4aa6('0x58')],null))[_0x4aa6('0x36')](respondWithResult(_0xc6d885,null))[_0x4aa6('0x56')](handleError(_0xc6d885,null));};exports[_0x4aa6('0x37')]=function(_0x317ceb,_0xc936cc){return db[_0x4aa6('0x50')][_0x4aa6('0x59')]({'where':{'id':_0x317ceb[_0x4aa6('0x54')]['id']}})['then'](handleEntityNotFound(_0xc936cc,null))[_0x4aa6('0x36')](removeEntity(_0xc936cc,null))[_0x4aa6('0x56')](handleError(_0xc936cc,null));};exports['describe']=function(_0x2bdec8,_0x4b41ec){return db[_0x4aa6('0x50')][_0x4aa6('0x5a')]()[_0x4aa6('0x36')](respondWithResult(_0x4b41ec,null))[_0x4aa6('0x56')](handleError(_0x4b41ec,null));};var interaction_log=require(_0x4aa6('0x5b'))('sms-interactions');exports[_0x4aa6('0x5c')]=function(_0x51c281,_0x158ec0,_0x215998){var _0x3d38dd={'agent':{},'channel':'sms'};if(_0x51c281[_0x4aa6('0x58')]['id']){delete _0x51c281[_0x4aa6('0x58')]['id'];}_0x51c281[_0x4aa6('0x58')]['read']=!![];_0x51c281['body']['readAt']=moment()['format'](_0x4aa6('0x5d'));_0x51c281[_0x4aa6('0x58')]['UserId']=_0x51c281['body'][_0x4aa6('0x5e')]||_0x51c281[_0x4aa6('0x5f')]['id'];_0x3d38dd[_0x4aa6('0x60')]['id']=_0x51c281[_0x4aa6('0x58')][_0x4aa6('0x5e')];return db[_0x4aa6('0x50')][_0x4aa6('0x59')]({'where':{'id':_0x51c281[_0x4aa6('0x54')]['id'],'UserId':null}})[_0x4aa6('0x36')](handleEntityNotFound(_0x158ec0,null))[_0x4aa6('0x36')](saveUpdates(_0x51c281[_0x4aa6('0x58')],null))[_0x4aa6('0x36')](function(_0x32d002){if(_0x32d002){_0x3d38dd[_0x4aa6('0x27')]=_0x32d002[_0x4aa6('0x61')]({'plain':!![]});return db['SmsInteraction'][_0x4aa6('0x59')]({'where':{'id':_0x32d002[_0x4aa6('0x62')]}});}return null;})[_0x4aa6('0x36')](handleEntityNotFound(_0x158ec0,null))[_0x4aa6('0x36')](function(_0x3475df){if(_0x3475df){return _0x3475df['update']({'UserId':_0x51c281[_0x4aa6('0x58')][_0x4aa6('0x5e')],'read1stAt':_[_0x4aa6('0x63')](_0x3475df['read1stAt'])?moment()[_0x4aa6('0x64')](_0x4aa6('0x5d')):undefined});}return null;})['then'](function(_0x3ff663){if(_0x3ff663){_0x3d38dd[_0x4aa6('0x65')]=_0x3ff663['get']({'plain':!![]});interaction_log[_0x4aa6('0x20')](_0x4aa6('0x66'),_0x51c281[_0x4aa6('0x5f')]['id'],_0x51c281['user'][_0x4aa6('0x38')],_0x51c281[_0x4aa6('0x5f')][_0x4aa6('0x67')],_0x3d38dd[_0x4aa6('0x65')]['id'],_0x51c281[_0x4aa6('0x58')]?JSON[_0x4aa6('0x25')](_0x51c281[_0x4aa6('0x58')]):_0x4aa6('0x68'));return respondWithRpcPromise('AcceptMessage',_0x4aa6('0x69'),_0x3d38dd);}return null;})[_0x4aa6('0x36')](function(_0x59a705){var _0x4ab963=_0x4aa6('0x6a')+_0x59a705[_0x4aa6('0x27')]['ContactId'];return db[_0x4aa6('0x6b')]['query'](_0x4ab963,{'type':db[_0x4aa6('0x6c')]['QueryTypes'][_0x4aa6('0x6d')],'raw':!![]})[_0x4aa6('0x36')](function(_0x56d929){return _0x56d929;});})[_0x4aa6('0x36')](function(_0x324c4a){if(_0x324c4a){_0x3d38dd[_0x4aa6('0x27')][_0x4aa6('0x6e')]=_0x324c4a[0x0];if(!_0x51c281[_0x4aa6('0x58')]['UserId'])return;return db['User'][_0x4aa6('0x59')]({'where':{'id':_0x51c281[_0x4aa6('0x58')][_0x4aa6('0x5e')],'role':_0x4aa6('0x60')},'attributes':['id',_0x4aa6('0x38'),_0x4aa6('0x6f'),_0x4aa6('0x70'),_0x4aa6('0x71')],'raw':!![]});}return null;})[_0x4aa6('0x36')](function(_0x26a145){if(!_0x26a145)return null;_0x3d38dd['message'][_0x4aa6('0x60')]=_0x26a145;return _0x3d38dd;})['then'](function(_0xb0c64b){if(_0xb0c64b){if(_0x51c281[_0x4aa6('0x58')][_0x4aa6('0x72')]){_0x3d38dd[_0x4aa6('0x27')]['interface']=util[_0x4aa6('0x64')](_0x4aa6('0x73'),_0x51c281['user'][_0x4aa6('0x38')]);_0x3d38dd[_0x4aa6('0x27')][_0x4aa6('0x74')]=_0x3d38dd[_0x4aa6('0x74')];_0x3d38dd[_0x4aa6('0x27')][_0x4aa6('0x75')]=_0x3d38dd[_0x4aa6('0x74')];_0x3d38dd[_0x4aa6('0x27')][_0x4aa6('0x76')]=_0x4aa6('0x5c');return respondWithRpcPromise(_0x4aa6('0x77'),_0x4aa6('0x77'),{'event':_0x4aa6('0x78'),'message':_0x3d38dd['message']},client9002)[_0x4aa6('0x36')](function(){return _0x3d38dd;});}return _0x3d38dd;}return null;})[_0x4aa6('0x36')](respondWithResult(_0x158ec0,null))[_0x4aa6('0x56')](handleError(_0x158ec0,null));};var interaction_log=require(_0x4aa6('0x5b'))('sms-interactions');exports[_0x4aa6('0x33')]=function(_0xdf485a,_0x39790f,_0x587b25){var _0xbd8423={'agent':{},'channel':_0x4aa6('0x79')};if(_0xdf485a[_0x4aa6('0x58')]['id']){delete _0xdf485a[_0x4aa6('0x58')]['id'];}_0xdf485a['body'][_0x4aa6('0x5e')]=_0xdf485a[_0x4aa6('0x58')][_0x4aa6('0x5e')]||_0xdf485a[_0x4aa6('0x5f')]['id'];_0xbd8423[_0x4aa6('0x60')]['id']=_0xdf485a['body']['UserId'];return db['SmsMessage'][_0x4aa6('0x59')]({'where':{'id':_0xdf485a[_0x4aa6('0x54')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x39790f,null))['then'](function(_0x31d1d9){if(_0x31d1d9){_0xbd8423[_0x4aa6('0x27')]=_0x31d1d9['get']({'plain':!![]});return db['SmsInteraction']['find']({'where':{'id':_0x31d1d9['SmsInteractionId']}});}return null;})[_0x4aa6('0x36')](handleEntityNotFound(_0x39790f,null))['then'](function(_0x120de2){if(_0x120de2){_0xbd8423[_0x4aa6('0x65')]=_0x120de2[_0x4aa6('0x61')]({'plain':!![]});interaction_log[_0x4aa6('0x20')]('[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0xdf485a['user']['id'],_0xdf485a[_0x4aa6('0x5f')][_0x4aa6('0x38')],_0xdf485a[_0x4aa6('0x5f')][_0x4aa6('0x67')],_0xbd8423[_0x4aa6('0x65')]['id'],_0xdf485a['body']?JSON[_0x4aa6('0x25')](_0xdf485a[_0x4aa6('0x58')]):_0x4aa6('0x68'));return respondWithRpcPromise(_0x4aa6('0x7a'),_0x4aa6('0x7b'),_0xbd8423);}return null;})[_0x4aa6('0x36')](function(_0x514400){var _0xcaee59=_0x4aa6('0x6a')+_0x514400[_0x4aa6('0x27')][_0x4aa6('0x7c')];return db[_0x4aa6('0x6b')][_0x4aa6('0x40')](_0xcaee59,{'type':db[_0x4aa6('0x6c')][_0x4aa6('0x7d')][_0x4aa6('0x6d')],'raw':!![]})['then'](function(_0x5640fd){return _0x5640fd;});})[_0x4aa6('0x36')](function(_0x34da8f){if(_0x34da8f){_0xbd8423[_0x4aa6('0x27')][_0x4aa6('0x6e')]=_0x34da8f[0x0];if(!_0xdf485a[_0x4aa6('0x58')][_0x4aa6('0x5e')])return;return db[_0x4aa6('0x7e')][_0x4aa6('0x59')]({'where':{'id':_0xdf485a[_0x4aa6('0x58')]['UserId'],'role':'agent'},'attributes':['id','name','fullname',_0x4aa6('0x70'),_0x4aa6('0x71')],'raw':!![]});}return null;})[_0x4aa6('0x36')](function(_0x10e1d1){if(!_0x10e1d1)return null;_0xbd8423['message'][_0x4aa6('0x60')]=_0x10e1d1;return _0xbd8423;})[_0x4aa6('0x36')](function(_0x38baba){if(_0x38baba){_0x38baba[_0x4aa6('0x27')][_0x4aa6('0x7f')]=util[_0x4aa6('0x64')](_0x4aa6('0x73'),_0xdf485a[_0x4aa6('0x5f')][_0x4aa6('0x38')]);_0x38baba[_0x4aa6('0x27')]['channel']=_0xbd8423[_0x4aa6('0x74')];_0x38baba['message'][_0x4aa6('0x75')]=_0xbd8423[_0x4aa6('0x74')];_0x38baba[_0x4aa6('0x27')][_0x4aa6('0x76')]=_0x4aa6('0x33');respondWithRpcPromise(_0x4aa6('0x77'),'EventManager',{'event':'rejectmessage','message':_0x38baba[_0x4aa6('0x27')]},client9002);return _0xbd8423;}return null;})[_0x4aa6('0x36')](respondWithResult(_0x39790f,null))[_0x4aa6('0x56')](handleError(_0x39790f,null));};exports[_0x4aa6('0x2a')]=function(_0x1847c0,_0x15f05c,_0x3b670b){if(_0x1847c0[_0x4aa6('0x58')]['id']){delete _0x1847c0['body']['id'];}var _0x14f9bb;return db[_0x4aa6('0x50')][_0x4aa6('0x59')]({'where':{'id':_0x1847c0[_0x4aa6('0x54')]['id']}})['then'](handleEntityNotFound(_0x15f05c,null))['then'](function(_0x2d1807){if(_0x2d1807){_0x14f9bb=_0x2d1807;return db['SmsAccount'][_0x4aa6('0x59')]({'where':{'id':_0x2d1807[_0x4aa6('0x80')]}});}})[_0x4aa6('0x36')](handleEntityNotFound(_0x15f05c,null))[_0x4aa6('0x36')](function(_0x2bcede){if(_0x2bcede){logger[_0x4aa6('0x23')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x4aa6('0x2a'),'received\x20delivery\x20report\x20from',_0x2bcede[_0x4aa6('0x3d')],util[_0x4aa6('0x81')](_0x1847c0[_0x4aa6('0x58')],{'showHidden':![],'depth':null}));switch(_0x2bcede[_0x4aa6('0x3d')]){case _0x4aa6('0x82'):if(_0x1847c0['body'][_0x4aa6('0x83')]&&_0x1847c0[_0x4aa6('0x58')]['MessageSid']===_0x14f9bb[_0x4aa6('0x84')]){return _0x14f9bb[_0x4aa6('0x35')]({'read':!![]});}else{logger[_0x4aa6('0x26')]('SmsAccount,\x20%s,\x20%s,\x20%s','status','twilio',util[_0x4aa6('0x81')](_0x1847c0[_0x4aa6('0x58')],{'showHidden':![],'depth':null}));}break;case _0x4aa6('0x85'):if(_0x1847c0[_0x4aa6('0x58')][_0x4aa6('0x86')]&&_0x1847c0[_0x4aa6('0x58')][_0x4aa6('0x86')]===_0x14f9bb[_0x4aa6('0x84')]&&_[_0x4aa6('0x87')]([_0x4aa6('0x88'),_0x4aa6('0x89')],_0x1847c0['body'][_0x4aa6('0x8a')])>=0x0){return _0x14f9bb[_0x4aa6('0x35')]({'read':!![]});}else{logger[_0x4aa6('0x26')](_0x4aa6('0x8b'),_0x4aa6('0x2a'),_0x4aa6('0x8c'),util[_0x4aa6('0x81')](_0x1847c0['body'],{'showHidden':![],'depth':null}));}break;case _0x4aa6('0x8d'):var _0x56df9d=_0x1847c0[_0x4aa6('0x58')][_0x4aa6('0x8e')][0x0];if(_0x56df9d[_0x4aa6('0x2a')][_0x4aa6('0x8f')]===_0x4aa6('0x90')){return _0x14f9bb[_0x4aa6('0x35')]({'read':!![]});}else{logger[_0x4aa6('0x26')](_0x4aa6('0x8b'),_0x4aa6('0x2a'),_0x4aa6('0x8d'),util[_0x4aa6('0x81')](_0x1847c0[_0x4aa6('0x58')],{'showHidden':![],'depth':null}));}break;}return _0x14f9bb;}})[_0x4aa6('0x36')](respondWithResult(_0x15f05c,null))[_0x4aa6('0x56')](handleError(_0x15f05c,null));};
\ No newline at end of file
+var _0x89fb=['SmsInteraction','SmsInteractionId','[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','contact','User','motionChannel','rejectmessage','SmsAccountId','debug','received\x20delivery\x20report\x20from','inspect','messageId','SmsAccount,\x20%s,\x20%s,\x20%s','twilio','plivo','MessageUUID','indexOf','sent','delivered','Status','infobip','results','groupName','DELIVERED','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','fs-extra','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./smsMessage.socket','jayson/promise','client','http','info','SmsMessage,\x20%s,\x20%s','SmsMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','sendStatus','status','end','json','limit','undefined','count','offset','Content-Range','reject','save','then','destroy','stack','name','send','map','SmsMessage','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','findAll','rows','show','params','rawAttributes','include','options','find','create','body','update','describe','../../config/logger','sms-interactions','accept','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','agent','get','isNil','read1stAt','interaction','user','role','null','acceptMessage','sequelize','QueryTypes','SELECT','fullname','email','internal','manual','interface','SIP/%s','channel','event','EventManager','acceptmessage'];(function(_0x341e0f,_0x4a09d0){var _0x59555a=function(_0x4343a8){while(--_0x4343a8){_0x341e0f['push'](_0x341e0f['shift']());}};_0x59555a(++_0x4a09d0);}(_0x89fb,0x14b));var _0xb89f=function(_0x5a152b,_0x341c18){_0x5a152b=_0x5a152b-0x0;var _0x25c8b1=_0x89fb[_0x5a152b];return _0x25c8b1;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb89f('0x0'));var zipdir=require(_0xb89f('0x1'));var jsonpatch=require(_0xb89f('0x2'));var rp=require(_0xb89f('0x3'));var moment=require(_0xb89f('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xb89f('0x5'));var util=require(_0xb89f('0x6'));var path=require(_0xb89f('0x7'));var sox=require(_0xb89f('0x8'));var csv=require(_0xb89f('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb89f('0xa'));var _=require('lodash');var squel=require(_0xb89f('0xb'));var crypto=require('crypto');var jsforce=require(_0xb89f('0xc'));var deskjs=require(_0xb89f('0xd'));var toCsv=require(_0xb89f('0x9'));var querystring=require('querystring');var Papa=require(_0xb89f('0xe'));var Redis=require(_0xb89f('0xf'));var authService=require(_0xb89f('0x10'));var qs=require(_0xb89f('0x11'));var as=require(_0xb89f('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xb89f('0x13'));var utils=require(_0xb89f('0x14'));var config=require(_0xb89f('0x15'));var licenseUtil=require(_0xb89f('0x16'));var db=require(_0xb89f('0x17'))['db'];config['redis']=_[_0xb89f('0x18')](config[_0xb89f('0x19')],{'host':_0xb89f('0x1a'),'port':0x18eb});var socket=require(_0xb89f('0x1b'))(new Redis(config[_0xb89f('0x19')]));require(_0xb89f('0x1c'))['register'](socket);var jayson=require(_0xb89f('0x1d'));var client=jayson[_0xb89f('0x1e')][_0xb89f('0x1f')]({'port':0x232c});var client9002=jayson[_0xb89f('0x1e')][_0xb89f('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x10ffba,_0xb33497,_0x4d7a92,_0x243388){return new BPromise(function(_0xfc48d,_0x236c5b){var _0x43b231=_0x243388||client;return _0x43b231['request'](_0x10ffba,_0x4d7a92)['then'](function(_0x77a882){logger[_0xb89f('0x20')](_0xb89f('0x21'),_0xb33497,'request\x20sent');logger['debug'](_0xb89f('0x22'),_0xb33497,_0xb89f('0x23'),JSON[_0xb89f('0x24')](_0x77a882));if(_0x77a882[_0xb89f('0x25')]){if(_0x77a882[_0xb89f('0x25')][_0xb89f('0x26')]===0x1f4){logger[_0xb89f('0x25')]('SmsMessage,\x20%s,\x20%s',_0xb33497,_0x77a882['error']['message']);return _0x236c5b(_0x77a882['error']['message']);}logger[_0xb89f('0x25')]('SmsMessage,\x20%s,\x20%s',_0xb33497,_0x77a882[_0xb89f('0x25')][_0xb89f('0x27')]);return _0xfc48d(_0x77a882[_0xb89f('0x25')][_0xb89f('0x27')]);}else{logger[_0xb89f('0x20')](_0xb89f('0x21'),_0xb33497,'request\x20sent');_0xfc48d(_0x77a882[_0xb89f('0x28')][_0xb89f('0x27')]);}})[_0xb89f('0x29')](function(_0x3b3829){logger[_0xb89f('0x25')](_0xb89f('0x21'),_0xb33497,_0x3b3829);_0x236c5b(_0x3b3829);});});}function respondWithStatusCode(_0x1934e8,_0x177db8){_0x177db8=_0x177db8||0xcc;return function(_0x4bef2e){if(_0x4bef2e){return _0x1934e8[_0xb89f('0x2a')](_0x177db8);}return _0x1934e8[_0xb89f('0x2b')](_0x177db8)[_0xb89f('0x2c')]();};}function respondWithResult(_0x38983e,_0x1defa1){_0x1defa1=_0x1defa1||0xc8;return function(_0x22195c){if(_0x22195c){return _0x38983e['status'](_0x1defa1)[_0xb89f('0x2d')](_0x22195c);}};}function respondWithFilteredResult(_0x22b15f,_0x289d88){return function(_0x2ab40c){if(_0x2ab40c){var _0x4eb8da=typeof _0x289d88['offset']==='undefined'&&typeof _0x289d88[_0xb89f('0x2e')]===_0xb89f('0x2f');var _0x3ce71d=_0x2ab40c[_0xb89f('0x30')];var _0x283091=_0x4eb8da?0x0:_0x289d88[_0xb89f('0x31')];var _0x215925=_0x4eb8da?_0x2ab40c[_0xb89f('0x30')]:_0x289d88[_0xb89f('0x31')]+_0x289d88['limit'];var _0x17076d;if(_0x215925>=_0x3ce71d){_0x215925=_0x3ce71d;_0x17076d=0xc8;}else{_0x17076d=0xce;}_0x22b15f[_0xb89f('0x2b')](_0x17076d);return _0x22b15f['set'](_0xb89f('0x32'),_0x283091+'-'+_0x215925+'/'+_0x3ce71d)[_0xb89f('0x2d')](_0x2ab40c);}return null;};}function patchUpdates(_0x11ddbc){return function(_0xa0833d){try{jsonpatch['apply'](_0xa0833d,_0x11ddbc,!![]);}catch(_0x39cd78){return BPromise[_0xb89f('0x33')](_0x39cd78);}return _0xa0833d[_0xb89f('0x34')]();};}function saveUpdates(_0x11cef3,_0x4cda3d){return function(_0x4c2695){if(_0x4c2695){return _0x4c2695['update'](_0x11cef3)[_0xb89f('0x35')](function(_0x1cc704){return _0x1cc704;});}return null;};}function removeEntity(_0x3909a8,_0x4a5c19){return function(_0x465e68){if(_0x465e68){return _0x465e68[_0xb89f('0x36')]()[_0xb89f('0x35')](function(){_0x3909a8['status'](0xcc)[_0xb89f('0x2c')]();});}};}function handleEntityNotFound(_0x18578f,_0x19ad82){return function(_0x3fa6e6){if(!_0x3fa6e6){_0x18578f[_0xb89f('0x2a')](0x194);}return _0x3fa6e6;};}function handleError(_0x3a27a9,_0x3e49f4){_0x3e49f4=_0x3e49f4||0x1f4;return function(_0x4d70d2){logger[_0xb89f('0x25')](_0x4d70d2[_0xb89f('0x37')]);if(_0x4d70d2[_0xb89f('0x38')]){delete _0x4d70d2[_0xb89f('0x38')];}_0x3a27a9['status'](_0x3e49f4)[_0xb89f('0x39')](_0x4d70d2);};}exports['index']=function(_0x388606,_0x1bea30){var _0x5dc041={},_0x1b07b7={},_0x10ab12={'count':0x0,'rows':[]};var _0x2462cd=_[_0xb89f('0x3a')](db[_0xb89f('0x3b')]['rawAttributes'],function(_0x5d7b55){return{'name':_0x5d7b55[_0xb89f('0x3c')],'type':_0x5d7b55[_0xb89f('0x3d')][_0xb89f('0x3e')]};});_0x1b07b7[_0xb89f('0x3f')]=_[_0xb89f('0x3a')](_0x2462cd,_0xb89f('0x38'));_0x1b07b7['query']=_[_0xb89f('0x40')](_0x388606[_0xb89f('0x41')]);_0x1b07b7[_0xb89f('0x42')]=_[_0xb89f('0x43')](_0x1b07b7['model'],_0x1b07b7[_0xb89f('0x41')]);_0x5dc041[_0xb89f('0x44')]=_[_0xb89f('0x43')](_0x1b07b7['model'],qs[_0xb89f('0x45')](_0x388606[_0xb89f('0x41')][_0xb89f('0x45')]));_0x5dc041['attributes']=_0x5dc041[_0xb89f('0x44')][_0xb89f('0x46')]?_0x5dc041['attributes']:_0x1b07b7['model'];if(!_0x388606['query']['hasOwnProperty'](_0xb89f('0x47'))){_0x5dc041['limit']=qs[_0xb89f('0x2e')](_0x388606[_0xb89f('0x41')][_0xb89f('0x2e')]);_0x5dc041[_0xb89f('0x31')]=qs['offset'](_0x388606[_0xb89f('0x41')][_0xb89f('0x31')]);}_0x5dc041[_0xb89f('0x48')]=qs[_0xb89f('0x49')](_0x388606[_0xb89f('0x41')][_0xb89f('0x49')]);_0x5dc041[_0xb89f('0x4a')]=qs[_0xb89f('0x42')](_[_0xb89f('0x4b')](_0x388606[_0xb89f('0x41')],_0x1b07b7[_0xb89f('0x42')]),_0x2462cd);if(_0x388606[_0xb89f('0x41')][_0xb89f('0x4c')]){_0x5dc041['where']=_[_0xb89f('0x4d')](_0x5dc041[_0xb89f('0x4a')],{'$or':_[_0xb89f('0x3a')](_0x2462cd,function(_0x46370b){if(_0x46370b[_0xb89f('0x3d')]!==_0xb89f('0x4e')){var _0x3b028e={};_0x3b028e[_0x46370b['name']]={'$like':'%'+_0x388606[_0xb89f('0x41')]['filter']+'%'};return _0x3b028e;}})});}_0x5dc041=_[_0xb89f('0x4d')]({},_0x5dc041,_0x388606['options']);var _0x7b3c1b={'where':_0x5dc041[_0xb89f('0x4a')]};return db[_0xb89f('0x3b')]['count'](_0x7b3c1b)[_0xb89f('0x35')](function(_0x5d315b){_0x10ab12[_0xb89f('0x30')]=_0x5d315b;if(_0x388606[_0xb89f('0x41')][_0xb89f('0x4f')]){_0x5dc041['include']=[{'all':!![]}];}return db[_0xb89f('0x3b')][_0xb89f('0x50')](_0x5dc041);})['then'](function(_0x667859){_0x10ab12[_0xb89f('0x51')]=_0x667859;return _0x10ab12;})[_0xb89f('0x35')](respondWithFilteredResult(_0x1bea30,_0x5dc041))[_0xb89f('0x29')](handleError(_0x1bea30,null));};exports[_0xb89f('0x52')]=function(_0x3c5421,_0x29ad5f){var _0x30109e={'raw':!![],'where':{'id':_0x3c5421[_0xb89f('0x53')]['id']}},_0x61e636={};_0x61e636['model']=_['keys'](db[_0xb89f('0x3b')][_0xb89f('0x54')]);_0x61e636[_0xb89f('0x41')]=_[_0xb89f('0x40')](_0x3c5421['query']);_0x61e636['filters']=_[_0xb89f('0x43')](_0x61e636['model'],_0x61e636['query']);_0x30109e[_0xb89f('0x44')]=_['intersection'](_0x61e636[_0xb89f('0x3f')],qs[_0xb89f('0x45')](_0x3c5421[_0xb89f('0x41')][_0xb89f('0x45')]));_0x30109e[_0xb89f('0x44')]=_0x30109e['attributes'][_0xb89f('0x46')]?_0x30109e[_0xb89f('0x44')]:_0x61e636[_0xb89f('0x3f')];if(_0x3c5421[_0xb89f('0x41')][_0xb89f('0x4f')]){_0x30109e[_0xb89f('0x55')]=[{'all':!![]}];}_0x30109e=_['merge']({},_0x30109e,_0x3c5421[_0xb89f('0x56')]);return db[_0xb89f('0x3b')][_0xb89f('0x57')](_0x30109e)[_0xb89f('0x35')](handleEntityNotFound(_0x29ad5f,null))[_0xb89f('0x35')](respondWithResult(_0x29ad5f,null))[_0xb89f('0x29')](handleError(_0x29ad5f,null));};exports[_0xb89f('0x58')]=function(_0x496c1d,_0x1f19bb){return db[_0xb89f('0x3b')]['create'](_0x496c1d[_0xb89f('0x59')],{})[_0xb89f('0x35')](respondWithResult(_0x1f19bb,0xc9))['catch'](handleError(_0x1f19bb,null));};exports[_0xb89f('0x5a')]=function(_0x33cede,_0x2ce1a0){if(_0x33cede['body']['id']){delete _0x33cede['body']['id'];}return db[_0xb89f('0x3b')][_0xb89f('0x57')]({'where':{'id':_0x33cede['params']['id']}})[_0xb89f('0x35')](handleEntityNotFound(_0x2ce1a0,null))['then'](saveUpdates(_0x33cede[_0xb89f('0x59')],null))[_0xb89f('0x35')](respondWithResult(_0x2ce1a0,null))[_0xb89f('0x29')](handleError(_0x2ce1a0,null));};exports[_0xb89f('0x36')]=function(_0x4608d6,_0x448aea){return db['SmsMessage'][_0xb89f('0x57')]({'where':{'id':_0x4608d6[_0xb89f('0x53')]['id']}})['then'](handleEntityNotFound(_0x448aea,null))[_0xb89f('0x35')](removeEntity(_0x448aea,null))[_0xb89f('0x29')](handleError(_0x448aea,null));};exports['describe']=function(_0x4918c0,_0x11b8ff){return db[_0xb89f('0x3b')][_0xb89f('0x5b')]()['then'](respondWithResult(_0x11b8ff,null))[_0xb89f('0x29')](handleError(_0x11b8ff,null));};var interaction_log=require(_0xb89f('0x5c'))(_0xb89f('0x5d'));exports[_0xb89f('0x5e')]=function(_0x462da9,_0x5c1500,_0x5d8d92){var _0xd8727={'agent':{},'channel':'sms'};if(_0x462da9[_0xb89f('0x59')]['id']){delete _0x462da9['body']['id'];}_0x462da9[_0xb89f('0x59')][_0xb89f('0x5f')]=!![];_0x462da9[_0xb89f('0x59')][_0xb89f('0x60')]=moment()[_0xb89f('0x61')](_0xb89f('0x62'));_0x462da9[_0xb89f('0x59')]['UserId']=_0x462da9[_0xb89f('0x59')][_0xb89f('0x63')]||_0x462da9['user']['id'];_0xd8727[_0xb89f('0x64')]['id']=_0x462da9[_0xb89f('0x59')]['UserId'];return db[_0xb89f('0x3b')][_0xb89f('0x57')]({'where':{'id':_0x462da9[_0xb89f('0x53')]['id'],'UserId':null}})[_0xb89f('0x35')](handleEntityNotFound(_0x5c1500,null))['then'](saveUpdates(_0x462da9[_0xb89f('0x59')],null))[_0xb89f('0x35')](function(_0xa2cedd){if(_0xa2cedd){_0xd8727[_0xb89f('0x27')]=_0xa2cedd[_0xb89f('0x65')]({'plain':!![]});return db['SmsInteraction'][_0xb89f('0x57')]({'where':{'id':_0xa2cedd['SmsInteractionId']}});}return null;})[_0xb89f('0x35')](handleEntityNotFound(_0x5c1500,null))[_0xb89f('0x35')](function(_0x56117e){if(_0x56117e){return _0x56117e[_0xb89f('0x5a')]({'UserId':_0x462da9[_0xb89f('0x59')]['UserId'],'read1stAt':_[_0xb89f('0x66')](_0x56117e[_0xb89f('0x67')])?moment()[_0xb89f('0x61')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0xb89f('0x35')](function(_0x2c489b){if(_0x2c489b){_0xd8727[_0xb89f('0x68')]=_0x2c489b['get']({'plain':!![]});interaction_log[_0xb89f('0x20')]('[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x462da9[_0xb89f('0x69')]['id'],_0x462da9[_0xb89f('0x69')][_0xb89f('0x38')],_0x462da9[_0xb89f('0x69')][_0xb89f('0x6a')],_0xd8727['interaction']['id'],_0x462da9[_0xb89f('0x59')]?JSON[_0xb89f('0x24')](_0x462da9[_0xb89f('0x59')]):_0xb89f('0x6b'));return respondWithRpcPromise('AcceptMessage',_0xb89f('0x6c'),_0xd8727);}return null;})[_0xb89f('0x35')](function(_0x742e1a){var _0xccb9e1='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x742e1a['message']['ContactId'];return db[_0xb89f('0x6d')][_0xb89f('0x41')](_0xccb9e1,{'type':db['Sequelize'][_0xb89f('0x6e')][_0xb89f('0x6f')],'raw':!![]})[_0xb89f('0x35')](function(_0x4df87d){return _0x4df87d;});})[_0xb89f('0x35')](function(_0x31e97c){if(_0x31e97c){_0xd8727[_0xb89f('0x27')]['contact']=_0x31e97c[0x0];if(!_0x462da9[_0xb89f('0x59')][_0xb89f('0x63')])return;return db['User'][_0xb89f('0x57')]({'where':{'id':_0x462da9[_0xb89f('0x59')][_0xb89f('0x63')],'role':_0xb89f('0x64')},'attributes':['id',_0xb89f('0x38'),_0xb89f('0x70'),_0xb89f('0x71'),_0xb89f('0x72')],'raw':!![]});}return null;})[_0xb89f('0x35')](function(_0x489a73){if(!_0x489a73)return null;_0xd8727[_0xb89f('0x27')]['agent']=_0x489a73;return _0xd8727;})[_0xb89f('0x35')](function(_0x2024c0){if(_0x2024c0){if(_0x462da9[_0xb89f('0x59')][_0xb89f('0x73')]){_0xd8727[_0xb89f('0x27')][_0xb89f('0x74')]=util[_0xb89f('0x61')](_0xb89f('0x75'),_0x462da9[_0xb89f('0x69')][_0xb89f('0x38')]);_0xd8727[_0xb89f('0x27')][_0xb89f('0x76')]=_0xd8727[_0xb89f('0x76')];_0xd8727[_0xb89f('0x27')]['motionChannel']=_0xd8727['channel'];_0xd8727[_0xb89f('0x27')][_0xb89f('0x77')]=_0xb89f('0x5e');return respondWithRpcPromise(_0xb89f('0x78'),_0xb89f('0x78'),{'event':_0xb89f('0x79'),'message':_0xd8727[_0xb89f('0x27')]},client9002)[_0xb89f('0x35')](function(){return _0xd8727;});}return _0xd8727;}return null;})[_0xb89f('0x35')](respondWithResult(_0x5c1500,null))[_0xb89f('0x29')](handleError(_0x5c1500,null));};var interaction_log=require(_0xb89f('0x5c'))(_0xb89f('0x5d'));exports[_0xb89f('0x33')]=function(_0x174181,_0x414b56,_0x1a7060){var _0x3ffd8f={'agent':{},'channel':'sms'};if(_0x174181[_0xb89f('0x59')]['id']){delete _0x174181[_0xb89f('0x59')]['id'];}_0x174181[_0xb89f('0x59')][_0xb89f('0x63')]=_0x174181['body']['UserId']||_0x174181[_0xb89f('0x69')]['id'];_0x3ffd8f[_0xb89f('0x64')]['id']=_0x174181['body'][_0xb89f('0x63')];return db[_0xb89f('0x3b')][_0xb89f('0x57')]({'where':{'id':_0x174181[_0xb89f('0x53')]['id'],'UserId':null}})[_0xb89f('0x35')](handleEntityNotFound(_0x414b56,null))[_0xb89f('0x35')](function(_0x497a15){if(_0x497a15){_0x3ffd8f[_0xb89f('0x27')]=_0x497a15[_0xb89f('0x65')]({'plain':!![]});return db[_0xb89f('0x7a')][_0xb89f('0x57')]({'where':{'id':_0x497a15[_0xb89f('0x7b')]}});}return null;})['then'](handleEntityNotFound(_0x414b56,null))[_0xb89f('0x35')](function(_0x819aa4){if(_0x819aa4){_0x3ffd8f[_0xb89f('0x68')]=_0x819aa4[_0xb89f('0x65')]({'plain':!![]});interaction_log['info'](_0xb89f('0x7c'),_0x174181['user']['id'],_0x174181['user'][_0xb89f('0x38')],_0x174181[_0xb89f('0x69')][_0xb89f('0x6a')],_0x3ffd8f[_0xb89f('0x68')]['id'],_0x174181[_0xb89f('0x59')]?JSON['stringify'](_0x174181['body']):_0xb89f('0x6b'));return respondWithRpcPromise(_0xb89f('0x7d'),_0xb89f('0x7e'),_0x3ffd8f);}return null;})[_0xb89f('0x35')](function(_0x1c1aa1){var _0x2ada7=_0xb89f('0x7f')+_0x1c1aa1['message'][_0xb89f('0x80')];return db['sequelize']['query'](_0x2ada7,{'type':db[_0xb89f('0x81')][_0xb89f('0x6e')][_0xb89f('0x6f')],'raw':!![]})[_0xb89f('0x35')](function(_0x16defe){return _0x16defe;});})[_0xb89f('0x35')](function(_0x541467){if(_0x541467){_0x3ffd8f[_0xb89f('0x27')][_0xb89f('0x82')]=_0x541467[0x0];if(!_0x174181[_0xb89f('0x59')]['UserId'])return;return db[_0xb89f('0x83')][_0xb89f('0x57')]({'where':{'id':_0x174181[_0xb89f('0x59')][_0xb89f('0x63')],'role':_0xb89f('0x64')},'attributes':['id',_0xb89f('0x38'),'fullname',_0xb89f('0x71'),_0xb89f('0x72')],'raw':!![]});}return null;})[_0xb89f('0x35')](function(_0x1ddf08){if(!_0x1ddf08)return null;_0x3ffd8f[_0xb89f('0x27')][_0xb89f('0x64')]=_0x1ddf08;return _0x3ffd8f;})[_0xb89f('0x35')](function(_0x272011){if(_0x272011){_0x272011['message']['interface']=util[_0xb89f('0x61')](_0xb89f('0x75'),_0x174181[_0xb89f('0x69')]['name']);_0x272011[_0xb89f('0x27')][_0xb89f('0x76')]=_0x3ffd8f[_0xb89f('0x76')];_0x272011['message'][_0xb89f('0x84')]=_0x3ffd8f[_0xb89f('0x76')];_0x272011['message'][_0xb89f('0x77')]=_0xb89f('0x33');respondWithRpcPromise(_0xb89f('0x78'),_0xb89f('0x78'),{'event':_0xb89f('0x85'),'message':_0x272011['message']},client9002);return _0x3ffd8f;}return null;})[_0xb89f('0x35')](respondWithResult(_0x414b56,null))[_0xb89f('0x29')](handleError(_0x414b56,null));};exports[_0xb89f('0x2b')]=function(_0x207fed,_0x11ba25,_0x181ee2){if(_0x207fed[_0xb89f('0x59')]['id']){delete _0x207fed['body']['id'];}var _0x3bf1a3;return db[_0xb89f('0x3b')][_0xb89f('0x57')]({'where':{'id':_0x207fed['params']['id']}})[_0xb89f('0x35')](handleEntityNotFound(_0x11ba25,null))[_0xb89f('0x35')](function(_0x2d0123){if(_0x2d0123){_0x3bf1a3=_0x2d0123;return db['SmsAccount'][_0xb89f('0x57')]({'where':{'id':_0x2d0123[_0xb89f('0x86')]}});}})[_0xb89f('0x35')](handleEntityNotFound(_0x11ba25,null))[_0xb89f('0x35')](function(_0x3baa1b){if(_0x3baa1b){logger[_0xb89f('0x87')](_0xb89f('0x22'),_0xb89f('0x2b'),_0xb89f('0x88'),_0x3baa1b['type'],util[_0xb89f('0x89')](_0x207fed[_0xb89f('0x59')],{'showHidden':![],'depth':null}));switch(_0x3baa1b[_0xb89f('0x3d')]){case'twilio':if(_0x207fed['body']['MessageSid']&&_0x207fed[_0xb89f('0x59')]['MessageSid']===_0x3bf1a3[_0xb89f('0x8a')]){return _0x3bf1a3[_0xb89f('0x5a')]({'read':!![]});}else{logger[_0xb89f('0x25')](_0xb89f('0x8b'),_0xb89f('0x2b'),_0xb89f('0x8c'),util[_0xb89f('0x89')](_0x207fed[_0xb89f('0x59')],{'showHidden':![],'depth':null}));}break;case _0xb89f('0x8d'):if(_0x207fed['body']['MessageUUID']&&_0x207fed['body'][_0xb89f('0x8e')]===_0x3bf1a3[_0xb89f('0x8a')]&&_[_0xb89f('0x8f')]([_0xb89f('0x90'),_0xb89f('0x91')],_0x207fed[_0xb89f('0x59')][_0xb89f('0x92')])>=0x0){return _0x3bf1a3[_0xb89f('0x5a')]({'read':!![]});}else{logger['error'](_0xb89f('0x8b'),'status','plivio',util[_0xb89f('0x89')](_0x207fed[_0xb89f('0x59')],{'showHidden':![],'depth':null}));}break;case _0xb89f('0x93'):var _0xf9cd1=_0x207fed[_0xb89f('0x59')][_0xb89f('0x94')][0x0];if(_0xf9cd1[_0xb89f('0x2b')][_0xb89f('0x95')]===_0xb89f('0x96')){return _0x3bf1a3[_0xb89f('0x5a')]({'read':!![]});}else{logger[_0xb89f('0x25')](_0xb89f('0x8b'),_0xb89f('0x2b'),_0xb89f('0x93'),util['inspect'](_0x207fed[_0xb89f('0x59')],{'showHidden':![],'depth':null}));}break;}return _0x3bf1a3;}})[_0xb89f('0x35')](respondWithResult(_0x11ba25,null))[_0xb89f('0x29')](handleError(_0x11ba25,null));};
\ No newline at end of file