Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / openchannelMessage / openchannelMessage.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xb6b3=['papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','register','jayson/promise','client','http','request','then','info','OpenchannelMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','sendStatus','end','status','offset','undefined','limit','set','Content-Range','json','apply','reject','save','update','destroy','name','send','index','map','OpenchannelMessage','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','merge','VIRTUAL','filter','count','includeAll','include','findAll','show','options','find','create','body','params','describe','../../config/logger','openchannel-interactions','accept','openchannel','readAt','YYYY-MM-DD\x20HH:mm:ss','UserId','agent','get','OpenchannelInteraction','format','interaction','[OPENCHANNELMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','null','AcceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','SELECT','contact','User','fullname','email','internal','manual','interface','SIP/%s','channel','motionChannel','event','EventManager','acceptmessage','OpenchannelInteractionId','[OPENCHANNELMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','rejectMessage','sequelize','QueryTypes','rejectmessage','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring'];(function(_0x1ac595,_0x5d2081){var _0x455fff=function(_0x3043ee){while(--_0x3043ee){_0x1ac595['push'](_0x1ac595['shift']());}};_0x455fff(++_0x5d2081);}(_0xb6b3,0x76));var _0x3b6b=function(_0x10224e,_0x46a037){_0x10224e=_0x10224e-0x0;var _0x57e372=_0xb6b3[_0x10224e];return _0x57e372;};'use strict';var emlformat=require(_0x3b6b('0x0'));var rimraf=require(_0x3b6b('0x1'));var zipdir=require(_0x3b6b('0x2'));var jsonpatch=require(_0x3b6b('0x3'));var rp=require(_0x3b6b('0x4'));var moment=require('moment');var BPromise=require(_0x3b6b('0x5'));var Mustache=require(_0x3b6b('0x6'));var util=require('util');var path=require(_0x3b6b('0x7'));var sox=require('sox');var csv=require(_0x3b6b('0x8'));var ejs=require(_0x3b6b('0x9'));var fs=require('fs');var fs_extra=require(_0x3b6b('0xa'));var _=require(_0x3b6b('0xb'));var squel=require(_0x3b6b('0xc'));var crypto=require('crypto');var jsforce=require(_0x3b6b('0xd'));var deskjs=require(_0x3b6b('0xe'));var toCsv=require(_0x3b6b('0x8'));var querystring=require(_0x3b6b('0xf'));var Papa=require(_0x3b6b('0x10'));var Redis=require(_0x3b6b('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x3b6b('0x12'));var as=require(_0x3b6b('0x13'));var hardwareService=require(_0x3b6b('0x14'));var logger=require('../../config/logger')(_0x3b6b('0x15'));var utils=require(_0x3b6b('0x16'));var config=require(_0x3b6b('0x17'));var licenseUtil=require(_0x3b6b('0x18'));var db=require(_0x3b6b('0x19'))['db'];config[_0x3b6b('0x1a')]=_[_0x3b6b('0x1b')](config[_0x3b6b('0x1a')],{'host':'localhost','port':0x18eb});var socket=require(_0x3b6b('0x1c'))(new Redis(config['redis']));require('./openchannelMessage.socket')[_0x3b6b('0x1d')](socket);var jayson=require(_0x3b6b('0x1e'));var client=jayson[_0x3b6b('0x1f')]['http']({'port':0x232c});var client9002=jayson[_0x3b6b('0x1f')][_0x3b6b('0x20')]({'port':0x232a});function respondWithRpcPromise(_0x2e676f,_0x14d8fe,_0x38cb59,_0x4f4d0e){return new BPromise(function(_0x5d9b83,_0x1371dd){var _0x544475=_0x4f4d0e||client;return _0x544475[_0x3b6b('0x21')](_0x2e676f,_0x38cb59)[_0x3b6b('0x22')](function(_0x38f333){logger[_0x3b6b('0x23')](_0x3b6b('0x24'),_0x14d8fe,_0x3b6b('0x25'));logger[_0x3b6b('0x26')]('OpenchannelMessage,\x20%s,\x20%s,\x20%s',_0x14d8fe,'request\x20sent',JSON[_0x3b6b('0x27')](_0x38f333));if(_0x38f333[_0x3b6b('0x28')]){if(_0x38f333[_0x3b6b('0x28')][_0x3b6b('0x29')]===0x1f4){logger['error'](_0x3b6b('0x24'),_0x14d8fe,_0x38f333[_0x3b6b('0x28')]['message']);return _0x1371dd(_0x38f333['error'][_0x3b6b('0x2a')]);}logger[_0x3b6b('0x28')](_0x3b6b('0x24'),_0x14d8fe,_0x38f333[_0x3b6b('0x28')][_0x3b6b('0x2a')]);return _0x5d9b83(_0x38f333[_0x3b6b('0x28')][_0x3b6b('0x2a')]);}else{logger[_0x3b6b('0x23')](_0x3b6b('0x24'),_0x14d8fe,_0x3b6b('0x25'));_0x5d9b83(_0x38f333[_0x3b6b('0x2b')][_0x3b6b('0x2a')]);}})[_0x3b6b('0x2c')](function(_0x5eb579){logger[_0x3b6b('0x28')](_0x3b6b('0x24'),_0x14d8fe,_0x5eb579);_0x1371dd(_0x5eb579);});});}function respondWithStatusCode(_0x2c6479,_0x3355ad){_0x3355ad=_0x3355ad||0xcc;return function(_0x2b9908){if(_0x2b9908){return _0x2c6479[_0x3b6b('0x2d')](_0x3355ad);}return _0x2c6479['status'](_0x3355ad)[_0x3b6b('0x2e')]();};}function respondWithResult(_0x511e52,_0x13b5b1){_0x13b5b1=_0x13b5b1||0xc8;return function(_0x7b2169){if(_0x7b2169){return _0x511e52[_0x3b6b('0x2f')](_0x13b5b1)['json'](_0x7b2169);}};}function respondWithFilteredResult(_0x1293d4,_0x4542e6){return function(_0x476e8d){if(_0x476e8d){var _0x43bbb8=typeof _0x4542e6[_0x3b6b('0x30')]===_0x3b6b('0x31')&&typeof _0x4542e6[_0x3b6b('0x32')]===_0x3b6b('0x31');var _0x4bfe5f=_0x476e8d['count'];var _0x1e9396=_0x43bbb8?0x0:_0x4542e6['offset'];var _0x39a12f=_0x43bbb8?_0x476e8d['count']:_0x4542e6[_0x3b6b('0x30')]+_0x4542e6['limit'];var _0x126da8;if(_0x39a12f>=_0x4bfe5f){_0x39a12f=_0x4bfe5f;_0x126da8=0xc8;}else{_0x126da8=0xce;}_0x1293d4[_0x3b6b('0x2f')](_0x126da8);return _0x1293d4[_0x3b6b('0x33')](_0x3b6b('0x34'),_0x1e9396+'-'+_0x39a12f+'/'+_0x4bfe5f)[_0x3b6b('0x35')](_0x476e8d);}return null;};}function patchUpdates(_0x38ef4b){return function(_0x4c2205){try{jsonpatch[_0x3b6b('0x36')](_0x4c2205,_0x38ef4b,!![]);}catch(_0x2232d1){return BPromise[_0x3b6b('0x37')](_0x2232d1);}return _0x4c2205[_0x3b6b('0x38')]();};}function saveUpdates(_0x1f0240,_0x1342a0){return function(_0x33aa2d){if(_0x33aa2d){return _0x33aa2d[_0x3b6b('0x39')](_0x1f0240)[_0x3b6b('0x22')](function(_0x278dd7){return _0x278dd7;});}return null;};}function removeEntity(_0x151f0b,_0x5bc791){return function(_0x255a49){if(_0x255a49){return _0x255a49[_0x3b6b('0x3a')]()[_0x3b6b('0x22')](function(){_0x151f0b[_0x3b6b('0x2f')](0xcc)[_0x3b6b('0x2e')]();});}};}function handleEntityNotFound(_0x94a5b3,_0xc35079){return function(_0x185bfb){if(!_0x185bfb){_0x94a5b3['sendStatus'](0x194);}return _0x185bfb;};}function handleError(_0x10d7bf,_0x992d90){_0x992d90=_0x992d90||0x1f4;return function(_0x127b7c){logger['error'](_0x127b7c['stack']);if(_0x127b7c['name']){delete _0x127b7c[_0x3b6b('0x3b')];}_0x10d7bf['status'](_0x992d90)[_0x3b6b('0x3c')](_0x127b7c);};}exports[_0x3b6b('0x3d')]=function(_0x1246b9,_0x2a38dc){var _0x54c6ea={},_0x3f29c8={},_0x10af33={'count':0x0,'rows':[]};var _0x13ab34=_[_0x3b6b('0x3e')](db[_0x3b6b('0x3f')][_0x3b6b('0x40')],function(_0x2e5cd2){return{'name':_0x2e5cd2[_0x3b6b('0x41')],'type':_0x2e5cd2[_0x3b6b('0x42')][_0x3b6b('0x43')]};});_0x3f29c8[_0x3b6b('0x44')]=_[_0x3b6b('0x3e')](_0x13ab34,_0x3b6b('0x3b'));_0x3f29c8[_0x3b6b('0x45')]=_[_0x3b6b('0x46')](_0x1246b9['query']);_0x3f29c8[_0x3b6b('0x47')]=_[_0x3b6b('0x48')](_0x3f29c8[_0x3b6b('0x44')],_0x3f29c8[_0x3b6b('0x45')]);_0x54c6ea[_0x3b6b('0x49')]=_[_0x3b6b('0x48')](_0x3f29c8['model'],qs[_0x3b6b('0x4a')](_0x1246b9[_0x3b6b('0x45')][_0x3b6b('0x4a')]));_0x54c6ea[_0x3b6b('0x49')]=_0x54c6ea['attributes'][_0x3b6b('0x4b')]?_0x54c6ea[_0x3b6b('0x49')]:_0x3f29c8[_0x3b6b('0x44')];if(!_0x1246b9[_0x3b6b('0x45')][_0x3b6b('0x4c')](_0x3b6b('0x4d'))){_0x54c6ea[_0x3b6b('0x32')]=qs[_0x3b6b('0x32')](_0x1246b9[_0x3b6b('0x45')][_0x3b6b('0x32')]);_0x54c6ea[_0x3b6b('0x30')]=qs[_0x3b6b('0x30')](_0x1246b9[_0x3b6b('0x45')][_0x3b6b('0x30')]);}_0x54c6ea['order']=qs[_0x3b6b('0x4e')](_0x1246b9['query'][_0x3b6b('0x4e')]);_0x54c6ea[_0x3b6b('0x4f')]=qs[_0x3b6b('0x47')](_['pick'](_0x1246b9[_0x3b6b('0x45')],_0x3f29c8[_0x3b6b('0x47')]),_0x13ab34);if(_0x1246b9[_0x3b6b('0x45')]['filter']){_0x54c6ea['where']=_[_0x3b6b('0x50')](_0x54c6ea[_0x3b6b('0x4f')],{'$or':_[_0x3b6b('0x3e')](_0x13ab34,function(_0x2023cc){if(_0x2023cc[_0x3b6b('0x42')]!==_0x3b6b('0x51')){var _0xa4c2e4={};_0xa4c2e4[_0x2023cc[_0x3b6b('0x3b')]]={'$like':'%'+_0x1246b9[_0x3b6b('0x45')][_0x3b6b('0x52')]+'%'};return _0xa4c2e4;}})});}_0x54c6ea=_[_0x3b6b('0x50')]({},_0x54c6ea,_0x1246b9['options']);var _0x59fcbe={'where':_0x54c6ea[_0x3b6b('0x4f')]};return db[_0x3b6b('0x3f')]['count'](_0x59fcbe)[_0x3b6b('0x22')](function(_0x594666){_0x10af33[_0x3b6b('0x53')]=_0x594666;if(_0x1246b9[_0x3b6b('0x45')][_0x3b6b('0x54')]){_0x54c6ea[_0x3b6b('0x55')]=[{'all':!![]}];}return db[_0x3b6b('0x3f')][_0x3b6b('0x56')](_0x54c6ea);})[_0x3b6b('0x22')](function(_0x4714d6){_0x10af33['rows']=_0x4714d6;return _0x10af33;})[_0x3b6b('0x22')](respondWithFilteredResult(_0x2a38dc,_0x54c6ea))[_0x3b6b('0x2c')](handleError(_0x2a38dc,null));};exports[_0x3b6b('0x57')]=function(_0x25ac12,_0x29756b){var _0x41ec9f={'raw':!![],'where':{'id':_0x25ac12['params']['id']}},_0xba2552={};_0xba2552[_0x3b6b('0x44')]=_['keys'](db[_0x3b6b('0x3f')][_0x3b6b('0x40')]);_0xba2552[_0x3b6b('0x45')]=_[_0x3b6b('0x46')](_0x25ac12[_0x3b6b('0x45')]);_0xba2552[_0x3b6b('0x47')]=_[_0x3b6b('0x48')](_0xba2552[_0x3b6b('0x44')],_0xba2552[_0x3b6b('0x45')]);_0x41ec9f[_0x3b6b('0x49')]=_[_0x3b6b('0x48')](_0xba2552[_0x3b6b('0x44')],qs[_0x3b6b('0x4a')](_0x25ac12[_0x3b6b('0x45')][_0x3b6b('0x4a')]));_0x41ec9f['attributes']=_0x41ec9f[_0x3b6b('0x49')][_0x3b6b('0x4b')]?_0x41ec9f[_0x3b6b('0x49')]:_0xba2552['model'];if(_0x25ac12[_0x3b6b('0x45')]['includeAll']){_0x41ec9f[_0x3b6b('0x55')]=[{'all':!![]}];}_0x41ec9f=_[_0x3b6b('0x50')]({},_0x41ec9f,_0x25ac12[_0x3b6b('0x58')]);return db[_0x3b6b('0x3f')][_0x3b6b('0x59')](_0x41ec9f)[_0x3b6b('0x22')](handleEntityNotFound(_0x29756b,null))[_0x3b6b('0x22')](respondWithResult(_0x29756b,null))[_0x3b6b('0x2c')](handleError(_0x29756b,null));};exports[_0x3b6b('0x5a')]=function(_0x28b0ac,_0x27eddf){return db['OpenchannelMessage'][_0x3b6b('0x5a')](_0x28b0ac['body'],{})['then'](respondWithResult(_0x27eddf,0xc9))[_0x3b6b('0x2c')](handleError(_0x27eddf,null));};exports[_0x3b6b('0x39')]=function(_0x4b099c,_0x42f813){if(_0x4b099c[_0x3b6b('0x5b')]['id']){delete _0x4b099c[_0x3b6b('0x5b')]['id'];}return db[_0x3b6b('0x3f')][_0x3b6b('0x59')]({'where':{'id':_0x4b099c[_0x3b6b('0x5c')]['id']}})['then'](handleEntityNotFound(_0x42f813,null))[_0x3b6b('0x22')](saveUpdates(_0x4b099c[_0x3b6b('0x5b')],null))[_0x3b6b('0x22')](respondWithResult(_0x42f813,null))['catch'](handleError(_0x42f813,null));};exports[_0x3b6b('0x3a')]=function(_0xe980b5,_0xad39a){return db[_0x3b6b('0x3f')][_0x3b6b('0x59')]({'where':{'id':_0xe980b5[_0x3b6b('0x5c')]['id']}})[_0x3b6b('0x22')](handleEntityNotFound(_0xad39a,null))['then'](removeEntity(_0xad39a,null))[_0x3b6b('0x2c')](handleError(_0xad39a,null));};exports[_0x3b6b('0x5d')]=function(_0x246134,_0x203221){return db[_0x3b6b('0x3f')][_0x3b6b('0x5d')]()[_0x3b6b('0x22')](respondWithResult(_0x203221,null))[_0x3b6b('0x2c')](handleError(_0x203221,null));};var interaction_log=require(_0x3b6b('0x5e'))(_0x3b6b('0x5f'));exports[_0x3b6b('0x60')]=function(_0x4b2683,_0x30808d,_0x1b0c76){var _0x26b57a={'agent':{},'channel':_0x3b6b('0x61')};if(_0x4b2683['body']['id']){delete _0x4b2683['body']['id'];}_0x4b2683[_0x3b6b('0x5b')]['read']=!![];_0x4b2683[_0x3b6b('0x5b')][_0x3b6b('0x62')]=moment()['format'](_0x3b6b('0x63'));_0x4b2683[_0x3b6b('0x5b')][_0x3b6b('0x64')]=_0x4b2683[_0x3b6b('0x5b')][_0x3b6b('0x64')]||_0x4b2683['user']['id'];_0x26b57a[_0x3b6b('0x65')]['id']=_0x4b2683[_0x3b6b('0x5b')][_0x3b6b('0x64')];return db['OpenchannelMessage'][_0x3b6b('0x59')]({'where':{'id':_0x4b2683['params']['id'],'UserId':null}})[_0x3b6b('0x22')](handleEntityNotFound(_0x30808d,null))[_0x3b6b('0x22')](saveUpdates(_0x4b2683['body'],null))['then'](function(_0x24c485){if(_0x24c485){_0x26b57a[_0x3b6b('0x2a')]=_0x24c485[_0x3b6b('0x66')]({'plain':!![]});return db[_0x3b6b('0x67')][_0x3b6b('0x59')]({'where':{'id':_0x24c485['OpenchannelInteractionId']}});}return null;})[_0x3b6b('0x22')](handleEntityNotFound(_0x30808d,null))['then'](function(_0x145718){if(_0x145718){return _0x145718[_0x3b6b('0x39')]({'UserId':_0x4b2683['body']['UserId'],'read1stAt':_['isNil'](_0x145718['read1stAt'])?moment()[_0x3b6b('0x68')](_0x3b6b('0x63')):undefined});}return null;})['then'](function(_0x1e7b2d){if(_0x1e7b2d){_0x26b57a[_0x3b6b('0x69')]=_0x1e7b2d['get']({'plain':!![]});interaction_log[_0x3b6b('0x23')](_0x3b6b('0x6a'),_0x4b2683[_0x3b6b('0x6b')]['id'],_0x4b2683[_0x3b6b('0x6b')][_0x3b6b('0x3b')],_0x4b2683[_0x3b6b('0x6b')][_0x3b6b('0x6c')],_0x26b57a[_0x3b6b('0x69')]['id'],_0x4b2683[_0x3b6b('0x5b')]?JSON[_0x3b6b('0x27')](_0x4b2683['body']):_0x3b6b('0x6d'));return respondWithRpcPromise(_0x3b6b('0x6e'),'acceptMessage',_0x26b57a);}return null;})['then'](function(_0x5b7674){var _0x5e7aee=_0x3b6b('0x6f')+_0x5b7674['message'][_0x3b6b('0x70')];return db['sequelize'][_0x3b6b('0x45')](_0x5e7aee,{'type':db[_0x3b6b('0x71')]['QueryTypes'][_0x3b6b('0x72')],'raw':!![]})['then'](function(_0x2db442){return _0x2db442;});})[_0x3b6b('0x22')](function(_0x53ac3f){if(_0x53ac3f){_0x26b57a[_0x3b6b('0x2a')][_0x3b6b('0x73')]=_0x53ac3f[0x0];if(!_0x4b2683[_0x3b6b('0x5b')][_0x3b6b('0x64')])return;return db[_0x3b6b('0x74')][_0x3b6b('0x59')]({'where':{'id':_0x4b2683[_0x3b6b('0x5b')][_0x3b6b('0x64')],'role':'agent'},'attributes':['id','name',_0x3b6b('0x75'),_0x3b6b('0x76'),_0x3b6b('0x77')],'raw':!![]});}return null;})[_0x3b6b('0x22')](function(_0x3a10e6){if(!_0x3a10e6)return null;_0x26b57a['message']['agent']=_0x3a10e6;return _0x26b57a;})[_0x3b6b('0x22')](function(_0x356f1e){if(_0x356f1e){if(_0x4b2683[_0x3b6b('0x5b')][_0x3b6b('0x78')]){_0x26b57a[_0x3b6b('0x2a')][_0x3b6b('0x79')]=util[_0x3b6b('0x68')](_0x3b6b('0x7a'),_0x4b2683['user']['name']);_0x26b57a[_0x3b6b('0x2a')][_0x3b6b('0x7b')]=_0x26b57a['channel'];_0x26b57a['message'][_0x3b6b('0x7c')]=_0x26b57a[_0x3b6b('0x7b')];_0x26b57a[_0x3b6b('0x2a')][_0x3b6b('0x7d')]=_0x3b6b('0x60');return respondWithRpcPromise('EventManager',_0x3b6b('0x7e'),{'event':_0x3b6b('0x7f'),'message':_0x26b57a['message']},client9002)['then'](function(){return _0x26b57a;});}return _0x26b57a;}return null;})[_0x3b6b('0x22')](respondWithResult(_0x30808d,null))[_0x3b6b('0x2c')](handleError(_0x30808d,null));};var interaction_log=require(_0x3b6b('0x5e'))(_0x3b6b('0x5f'));exports[_0x3b6b('0x37')]=function(_0x3acdf2,_0x468d67,_0x383d63){var _0x194b0f={'agent':{},'channel':_0x3b6b('0x61')};if(_0x3acdf2['body']['id']){delete _0x3acdf2[_0x3b6b('0x5b')]['id'];}_0x3acdf2[_0x3b6b('0x5b')][_0x3b6b('0x64')]=_0x3acdf2[_0x3b6b('0x5b')][_0x3b6b('0x64')]||_0x3acdf2[_0x3b6b('0x6b')]['id'];_0x194b0f[_0x3b6b('0x65')]['id']=_0x3acdf2[_0x3b6b('0x5b')]['UserId'];return db[_0x3b6b('0x3f')][_0x3b6b('0x59')]({'where':{'id':_0x3acdf2[_0x3b6b('0x5c')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x468d67,null))['then'](function(_0x6173ff){if(_0x6173ff){_0x194b0f[_0x3b6b('0x2a')]=_0x6173ff[_0x3b6b('0x66')]({'plain':!![]});return db['OpenchannelInteraction']['find']({'where':{'id':_0x6173ff[_0x3b6b('0x80')]}});}return null;})[_0x3b6b('0x22')](handleEntityNotFound(_0x468d67,null))[_0x3b6b('0x22')](function(_0x3e2ea4){if(_0x3e2ea4){_0x194b0f['interaction']=_0x3e2ea4['get']({'plain':!![]});interaction_log[_0x3b6b('0x23')](_0x3b6b('0x81'),_0x3acdf2['user']['id'],_0x3acdf2[_0x3b6b('0x6b')][_0x3b6b('0x3b')],_0x3acdf2[_0x3b6b('0x6b')][_0x3b6b('0x6c')],_0x194b0f[_0x3b6b('0x69')]['id'],_0x3acdf2['body']?JSON[_0x3b6b('0x27')](_0x3acdf2[_0x3b6b('0x5b')]):_0x3b6b('0x6d'));return respondWithRpcPromise('RejectMessage',_0x3b6b('0x82'),_0x194b0f);}return null;})[_0x3b6b('0x22')](function(_0x55b58a){var _0xc1824b=_0x3b6b('0x6f')+_0x55b58a[_0x3b6b('0x2a')][_0x3b6b('0x70')];return db[_0x3b6b('0x83')][_0x3b6b('0x45')](_0xc1824b,{'type':db[_0x3b6b('0x71')][_0x3b6b('0x84')][_0x3b6b('0x72')],'raw':!![]})['then'](function(_0x8120b6){return _0x8120b6;});})[_0x3b6b('0x22')](function(_0xade37c){if(_0xade37c){_0x194b0f[_0x3b6b('0x2a')][_0x3b6b('0x73')]=_0xade37c[0x0];if(!_0x3acdf2['body'][_0x3b6b('0x64')])return;return db[_0x3b6b('0x74')][_0x3b6b('0x59')]({'where':{'id':_0x3acdf2[_0x3b6b('0x5b')][_0x3b6b('0x64')],'role':'agent'},'attributes':['id',_0x3b6b('0x3b'),_0x3b6b('0x75'),_0x3b6b('0x76'),_0x3b6b('0x77')],'raw':!![]});}return null;})[_0x3b6b('0x22')](function(_0x82be17){if(!_0x82be17)return null;_0x194b0f[_0x3b6b('0x2a')][_0x3b6b('0x65')]=_0x82be17;return _0x194b0f;})[_0x3b6b('0x22')](function(_0x1d1a02){if(_0x1d1a02){_0x1d1a02[_0x3b6b('0x2a')]['interface']=util['format'](_0x3b6b('0x7a'),_0x3acdf2[_0x3b6b('0x6b')][_0x3b6b('0x3b')]);_0x1d1a02[_0x3b6b('0x2a')][_0x3b6b('0x7b')]=_0x194b0f[_0x3b6b('0x7b')];_0x1d1a02[_0x3b6b('0x2a')][_0x3b6b('0x7c')]=_0x194b0f[_0x3b6b('0x7b')];_0x1d1a02['message']['event']=_0x3b6b('0x37');respondWithRpcPromise(_0x3b6b('0x7e'),_0x3b6b('0x7e'),{'event':_0x3b6b('0x85'),'message':_0x1d1a02['message']},client9002);return _0x194b0f;}return null;})[_0x3b6b('0x22')](respondWithResult(_0x468d67,null))[_0x3b6b('0x2c')](handleError(_0x468d67,null));};