Built motion from commit c738b9ac.|2.6.25
[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 _0x9fc5=['includeAll','options','create','body','find','describe','openchannel-interactions','accept','openchannel','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','OpenchannelInteraction','OpenchannelInteractionId','read1stAt','interaction','[OPENCHANNELMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','null','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','QueryTypes','SELECT','contact','User','email','internal','manual','SIP/%s','channel','motionChannel','event','EventManager','role','stringify','RejectMessage','rejectMessage','Sequelize','fullname','interface','rejectmessage','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./openchannelMessage.socket','register','jayson/promise','client','http','then','info','OpenchannelMessage,\x20%s,\x20%s','request\x20sent','debug','OpenchannelMessage,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','sendStatus','end','status','offset','limit','undefined','count','Content-Range','json','apply','reject','save','update','destroy','stack','name','map','OpenchannelMessage','rawAttributes','key','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','type','VIRTUAL','include','findAll','rows','show','params'];(function(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0x9fc5,0xb6));var _0x59fc=function(_0x58f245,_0x3e4f31){_0x58f245=_0x58f245-0x0;var _0x1f0cfb=_0x9fc5[_0x58f245];return _0x1f0cfb;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x59fc('0x0'));var zipdir=require(_0x59fc('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x59fc('0x2'));var moment=require(_0x59fc('0x3'));var BPromise=require(_0x59fc('0x4'));var Mustache=require(_0x59fc('0x5'));var util=require(_0x59fc('0x6'));var path=require(_0x59fc('0x7'));var sox=require(_0x59fc('0x8'));var csv=require(_0x59fc('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x59fc('0xa'));var _=require(_0x59fc('0xb'));var squel=require(_0x59fc('0xc'));var crypto=require('crypto');var jsforce=require(_0x59fc('0xd'));var deskjs=require(_0x59fc('0xe'));var toCsv=require(_0x59fc('0x9'));var querystring=require(_0x59fc('0xf'));var Papa=require(_0x59fc('0x10'));var Redis=require(_0x59fc('0x11'));var authService=require(_0x59fc('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x59fc('0x13'));var hardwareService=require(_0x59fc('0x14'));var logger=require(_0x59fc('0x15'))(_0x59fc('0x16'));var utils=require(_0x59fc('0x17'));var config=require(_0x59fc('0x18'));var licenseUtil=require(_0x59fc('0x19'));var db=require('../../mysqldb')['db'];config[_0x59fc('0x1a')]=_[_0x59fc('0x1b')](config[_0x59fc('0x1a')],{'host':_0x59fc('0x1c'),'port':0x18eb});var socket=require(_0x59fc('0x1d'))(new Redis(config[_0x59fc('0x1a')]));require(_0x59fc('0x1e'))[_0x59fc('0x1f')](socket);var jayson=require(_0x59fc('0x20'));var client=jayson[_0x59fc('0x21')][_0x59fc('0x22')]({'port':0x232c});var client9002=jayson['client'][_0x59fc('0x22')]({'port':0x232a});function respondWithRpcPromise(_0x362c6b,_0x4e01f6,_0x206b54,_0x44ef1d){return new BPromise(function(_0x4162c4,_0x1ddb29){var _0x175718=_0x44ef1d||client;return _0x175718['request'](_0x362c6b,_0x206b54)[_0x59fc('0x23')](function(_0x40fe8d){logger[_0x59fc('0x24')](_0x59fc('0x25'),_0x4e01f6,_0x59fc('0x26'));logger[_0x59fc('0x27')](_0x59fc('0x28'),_0x4e01f6,_0x59fc('0x26'),JSON['stringify'](_0x40fe8d));if(_0x40fe8d[_0x59fc('0x29')]){if(_0x40fe8d['error'][_0x59fc('0x2a')]===0x1f4){logger['error'](_0x59fc('0x25'),_0x4e01f6,_0x40fe8d[_0x59fc('0x29')][_0x59fc('0x2b')]);return _0x1ddb29(_0x40fe8d[_0x59fc('0x29')][_0x59fc('0x2b')]);}logger[_0x59fc('0x29')]('OpenchannelMessage,\x20%s,\x20%s',_0x4e01f6,_0x40fe8d[_0x59fc('0x29')][_0x59fc('0x2b')]);return _0x4162c4(_0x40fe8d['error']['message']);}else{logger[_0x59fc('0x24')](_0x59fc('0x25'),_0x4e01f6,_0x59fc('0x26'));_0x4162c4(_0x40fe8d[_0x59fc('0x2c')][_0x59fc('0x2b')]);}})[_0x59fc('0x2d')](function(_0x11e92e){logger[_0x59fc('0x29')](_0x59fc('0x25'),_0x4e01f6,_0x11e92e);_0x1ddb29(_0x11e92e);});});}function respondWithStatusCode(_0x5a2c5c,_0x3145be){_0x3145be=_0x3145be||0xcc;return function(_0x5e8669){if(_0x5e8669){return _0x5a2c5c[_0x59fc('0x2e')](_0x3145be);}return _0x5a2c5c['status'](_0x3145be)[_0x59fc('0x2f')]();};}function respondWithResult(_0x13dd35,_0x5573e5){_0x5573e5=_0x5573e5||0xc8;return function(_0x47121f){if(_0x47121f){return _0x13dd35[_0x59fc('0x30')](_0x5573e5)['json'](_0x47121f);}};}function respondWithFilteredResult(_0x1304ae,_0x3c6453){return function(_0x554cf8){if(_0x554cf8){var _0x222fe6=typeof _0x3c6453[_0x59fc('0x31')]==='undefined'&&typeof _0x3c6453[_0x59fc('0x32')]===_0x59fc('0x33');var _0x177828=_0x554cf8['count'];var _0x15146e=_0x222fe6?0x0:_0x3c6453[_0x59fc('0x31')];var _0x4f5e9f=_0x222fe6?_0x554cf8[_0x59fc('0x34')]:_0x3c6453[_0x59fc('0x31')]+_0x3c6453[_0x59fc('0x32')];var _0x158dae;if(_0x4f5e9f>=_0x177828){_0x4f5e9f=_0x177828;_0x158dae=0xc8;}else{_0x158dae=0xce;}_0x1304ae[_0x59fc('0x30')](_0x158dae);return _0x1304ae['set'](_0x59fc('0x35'),_0x15146e+'-'+_0x4f5e9f+'/'+_0x177828)[_0x59fc('0x36')](_0x554cf8);}return null;};}function patchUpdates(_0x369829){return function(_0x57795b){try{jsonpatch[_0x59fc('0x37')](_0x57795b,_0x369829,!![]);}catch(_0x56082e){return BPromise[_0x59fc('0x38')](_0x56082e);}return _0x57795b[_0x59fc('0x39')]();};}function saveUpdates(_0x18ff74,_0x4a1394){return function(_0x4bda35){if(_0x4bda35){return _0x4bda35[_0x59fc('0x3a')](_0x18ff74)[_0x59fc('0x23')](function(_0x2b703b){return _0x2b703b;});}return null;};}function removeEntity(_0x34ca70,_0x23fc2c){return function(_0x3610d0){if(_0x3610d0){return _0x3610d0[_0x59fc('0x3b')]()[_0x59fc('0x23')](function(){_0x34ca70[_0x59fc('0x30')](0xcc)[_0x59fc('0x2f')]();});}};}function handleEntityNotFound(_0x57367b,_0xa96105){return function(_0x37de7b){if(!_0x37de7b){_0x57367b[_0x59fc('0x2e')](0x194);}return _0x37de7b;};}function handleError(_0x3bdca5,_0x6c6af1){_0x6c6af1=_0x6c6af1||0x1f4;return function(_0x38eda6){logger['error'](_0x38eda6[_0x59fc('0x3c')]);if(_0x38eda6[_0x59fc('0x3d')]){delete _0x38eda6[_0x59fc('0x3d')];}_0x3bdca5['status'](_0x6c6af1)['send'](_0x38eda6);};}exports['index']=function(_0x538c49,_0x9bcea4){var _0xeeeb8b={},_0x4d33b7={},_0x465a77={'count':0x0,'rows':[]};var _0x2040c2=_[_0x59fc('0x3e')](db[_0x59fc('0x3f')][_0x59fc('0x40')],function(_0x14a67b){return{'name':_0x14a67b['fieldName'],'type':_0x14a67b['type'][_0x59fc('0x41')]};});_0x4d33b7[_0x59fc('0x42')]=_[_0x59fc('0x3e')](_0x2040c2,'name');_0x4d33b7[_0x59fc('0x43')]=_[_0x59fc('0x44')](_0x538c49[_0x59fc('0x43')]);_0x4d33b7['filters']=_['intersection'](_0x4d33b7[_0x59fc('0x42')],_0x4d33b7['query']);_0xeeeb8b['attributes']=_[_0x59fc('0x45')](_0x4d33b7[_0x59fc('0x42')],qs[_0x59fc('0x46')](_0x538c49[_0x59fc('0x43')]['fields']));_0xeeeb8b[_0x59fc('0x47')]=_0xeeeb8b[_0x59fc('0x47')][_0x59fc('0x48')]?_0xeeeb8b['attributes']:_0x4d33b7[_0x59fc('0x42')];if(!_0x538c49[_0x59fc('0x43')][_0x59fc('0x49')](_0x59fc('0x4a'))){_0xeeeb8b[_0x59fc('0x32')]=qs['limit'](_0x538c49[_0x59fc('0x43')][_0x59fc('0x32')]);_0xeeeb8b['offset']=qs[_0x59fc('0x31')](_0x538c49[_0x59fc('0x43')][_0x59fc('0x31')]);}_0xeeeb8b[_0x59fc('0x4b')]=qs['sort'](_0x538c49[_0x59fc('0x43')][_0x59fc('0x4c')]);_0xeeeb8b[_0x59fc('0x4d')]=qs[_0x59fc('0x4e')](_['pick'](_0x538c49[_0x59fc('0x43')],_0x4d33b7[_0x59fc('0x4e')]),_0x2040c2);if(_0x538c49[_0x59fc('0x43')][_0x59fc('0x4f')]){_0xeeeb8b[_0x59fc('0x4d')]=_[_0x59fc('0x50')](_0xeeeb8b[_0x59fc('0x4d')],{'$or':_[_0x59fc('0x3e')](_0x2040c2,function(_0x10dcf1){if(_0x10dcf1[_0x59fc('0x51')]!==_0x59fc('0x52')){var _0x50fad8={};_0x50fad8[_0x10dcf1[_0x59fc('0x3d')]]={'$like':'%'+_0x538c49['query'][_0x59fc('0x4f')]+'%'};return _0x50fad8;}})});}_0xeeeb8b=_[_0x59fc('0x50')]({},_0xeeeb8b,_0x538c49['options']);var _0x2922d5={'where':_0xeeeb8b[_0x59fc('0x4d')]};return db[_0x59fc('0x3f')]['count'](_0x2922d5)[_0x59fc('0x23')](function(_0x415ef4){_0x465a77['count']=_0x415ef4;if(_0x538c49[_0x59fc('0x43')]['includeAll']){_0xeeeb8b[_0x59fc('0x53')]=[{'all':!![]}];}return db[_0x59fc('0x3f')][_0x59fc('0x54')](_0xeeeb8b);})[_0x59fc('0x23')](function(_0x3a4e8a){_0x465a77[_0x59fc('0x55')]=_0x3a4e8a;return _0x465a77;})[_0x59fc('0x23')](respondWithFilteredResult(_0x9bcea4,_0xeeeb8b))[_0x59fc('0x2d')](handleError(_0x9bcea4,null));};exports[_0x59fc('0x56')]=function(_0x529f15,_0x169506){var _0x3b9ac5={'raw':!![],'where':{'id':_0x529f15[_0x59fc('0x57')]['id']}},_0x5a568b={};_0x5a568b[_0x59fc('0x42')]=_[_0x59fc('0x44')](db[_0x59fc('0x3f')][_0x59fc('0x40')]);_0x5a568b[_0x59fc('0x43')]=_[_0x59fc('0x44')](_0x529f15['query']);_0x5a568b[_0x59fc('0x4e')]=_[_0x59fc('0x45')](_0x5a568b[_0x59fc('0x42')],_0x5a568b[_0x59fc('0x43')]);_0x3b9ac5[_0x59fc('0x47')]=_['intersection'](_0x5a568b[_0x59fc('0x42')],qs[_0x59fc('0x46')](_0x529f15[_0x59fc('0x43')][_0x59fc('0x46')]));_0x3b9ac5[_0x59fc('0x47')]=_0x3b9ac5[_0x59fc('0x47')][_0x59fc('0x48')]?_0x3b9ac5[_0x59fc('0x47')]:_0x5a568b['model'];if(_0x529f15[_0x59fc('0x43')][_0x59fc('0x58')]){_0x3b9ac5['include']=[{'all':!![]}];}_0x3b9ac5=_[_0x59fc('0x50')]({},_0x3b9ac5,_0x529f15[_0x59fc('0x59')]);return db[_0x59fc('0x3f')]['find'](_0x3b9ac5)[_0x59fc('0x23')](handleEntityNotFound(_0x169506,null))[_0x59fc('0x23')](respondWithResult(_0x169506,null))[_0x59fc('0x2d')](handleError(_0x169506,null));};exports[_0x59fc('0x5a')]=function(_0x4f8d17,_0x62ec1b){return db[_0x59fc('0x3f')][_0x59fc('0x5a')](_0x4f8d17[_0x59fc('0x5b')],{})['then'](respondWithResult(_0x62ec1b,0xc9))['catch'](handleError(_0x62ec1b,null));};exports[_0x59fc('0x3a')]=function(_0x300c22,_0x4b85cf){if(_0x300c22[_0x59fc('0x5b')]['id']){delete _0x300c22[_0x59fc('0x5b')]['id'];}return db[_0x59fc('0x3f')][_0x59fc('0x5c')]({'where':{'id':_0x300c22['params']['id']}})[_0x59fc('0x23')](handleEntityNotFound(_0x4b85cf,null))['then'](saveUpdates(_0x300c22[_0x59fc('0x5b')],null))['then'](respondWithResult(_0x4b85cf,null))[_0x59fc('0x2d')](handleError(_0x4b85cf,null));};exports[_0x59fc('0x3b')]=function(_0x489262,_0x301ca9){return db[_0x59fc('0x3f')][_0x59fc('0x5c')]({'where':{'id':_0x489262[_0x59fc('0x57')]['id']}})[_0x59fc('0x23')](handleEntityNotFound(_0x301ca9,null))[_0x59fc('0x23')](removeEntity(_0x301ca9,null))[_0x59fc('0x2d')](handleError(_0x301ca9,null));};exports[_0x59fc('0x5d')]=function(_0x2c5026,_0x43da90){return db[_0x59fc('0x3f')][_0x59fc('0x5d')]()[_0x59fc('0x23')](respondWithResult(_0x43da90,null))[_0x59fc('0x2d')](handleError(_0x43da90,null));};var interaction_log=require(_0x59fc('0x15'))(_0x59fc('0x5e'));exports[_0x59fc('0x5f')]=function(_0x4515c9,_0x11ada6,_0x2a3310){var _0x167940={'agent':{},'channel':_0x59fc('0x60')};if(_0x4515c9['body']['id']){delete _0x4515c9[_0x59fc('0x5b')]['id'];}_0x4515c9[_0x59fc('0x5b')]['read']=!![];_0x4515c9[_0x59fc('0x5b')][_0x59fc('0x61')]=moment()[_0x59fc('0x62')](_0x59fc('0x63'));_0x4515c9[_0x59fc('0x5b')][_0x59fc('0x64')]=_0x4515c9[_0x59fc('0x5b')][_0x59fc('0x64')]||_0x4515c9[_0x59fc('0x65')]['id'];_0x167940[_0x59fc('0x66')]['id']=_0x4515c9[_0x59fc('0x5b')][_0x59fc('0x64')];return db[_0x59fc('0x3f')][_0x59fc('0x5c')]({'where':{'id':_0x4515c9[_0x59fc('0x57')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x11ada6,null))[_0x59fc('0x23')](saveUpdates(_0x4515c9[_0x59fc('0x5b')],null))[_0x59fc('0x23')](function(_0x47841b){if(_0x47841b){_0x167940[_0x59fc('0x2b')]=_0x47841b[_0x59fc('0x67')]({'plain':!![]});return db[_0x59fc('0x68')][_0x59fc('0x5c')]({'where':{'id':_0x47841b[_0x59fc('0x69')]}});}return null;})['then'](handleEntityNotFound(_0x11ada6,null))[_0x59fc('0x23')](function(_0x2648eb){if(_0x2648eb){return _0x2648eb['update']({'UserId':_0x4515c9[_0x59fc('0x5b')][_0x59fc('0x64')],'read1stAt':_['isNil'](_0x2648eb[_0x59fc('0x6a')])?moment()[_0x59fc('0x62')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0x59fc('0x23')](function(_0x318c14){if(_0x318c14){_0x167940[_0x59fc('0x6b')]=_0x318c14['get']({'plain':!![]});interaction_log[_0x59fc('0x24')](_0x59fc('0x6c'),_0x4515c9[_0x59fc('0x65')]['id'],_0x4515c9[_0x59fc('0x65')]['name'],_0x4515c9[_0x59fc('0x65')]['role'],_0x167940[_0x59fc('0x6b')]['id'],_0x4515c9[_0x59fc('0x5b')]?JSON['stringify'](_0x4515c9[_0x59fc('0x5b')]):_0x59fc('0x6d'));return respondWithRpcPromise(_0x59fc('0x6e'),_0x59fc('0x6f'),_0x167940);}return null;})[_0x59fc('0x23')](function(_0x33640e){var _0x323285=_0x59fc('0x70')+_0x33640e[_0x59fc('0x2b')][_0x59fc('0x71')];return db[_0x59fc('0x72')][_0x59fc('0x43')](_0x323285,{'type':db['Sequelize'][_0x59fc('0x73')][_0x59fc('0x74')],'raw':!![]})[_0x59fc('0x23')](function(_0x5536c4){return _0x5536c4;});})[_0x59fc('0x23')](function(_0xb9b287){if(_0xb9b287){_0x167940['message'][_0x59fc('0x75')]=_0xb9b287[0x0];if(!_0x4515c9['body'][_0x59fc('0x64')])return;return db[_0x59fc('0x76')][_0x59fc('0x5c')]({'where':{'id':_0x4515c9['body'][_0x59fc('0x64')],'role':_0x59fc('0x66')},'attributes':['id',_0x59fc('0x3d'),'fullname',_0x59fc('0x77'),_0x59fc('0x78')],'raw':!![]});}return null;})['then'](function(_0x45ef37){if(!_0x45ef37)return null;_0x167940[_0x59fc('0x2b')][_0x59fc('0x66')]=_0x45ef37;return _0x167940;})[_0x59fc('0x23')](function(_0x48301e){if(_0x48301e){if(_0x4515c9[_0x59fc('0x5b')][_0x59fc('0x79')]){_0x167940['message']['interface']=util['format'](_0x59fc('0x7a'),_0x4515c9['user'][_0x59fc('0x3d')]);_0x167940['message'][_0x59fc('0x7b')]=_0x167940[_0x59fc('0x7b')];_0x167940['message'][_0x59fc('0x7c')]=_0x167940[_0x59fc('0x7b')];_0x167940[_0x59fc('0x2b')][_0x59fc('0x7d')]=_0x59fc('0x5f');return respondWithRpcPromise(_0x59fc('0x7e'),'EventManager',{'event':'acceptmessage','message':_0x167940['message']},client9002)[_0x59fc('0x23')](function(){return _0x167940;});}return _0x167940;}return null;})[_0x59fc('0x23')](respondWithResult(_0x11ada6,null))[_0x59fc('0x2d')](handleError(_0x11ada6,null));};var interaction_log=require(_0x59fc('0x15'))(_0x59fc('0x5e'));exports[_0x59fc('0x38')]=function(_0x34933a,_0x1a366d,_0x157413){var _0x62cc4a={'agent':{},'channel':_0x59fc('0x60')};if(_0x34933a[_0x59fc('0x5b')]['id']){delete _0x34933a[_0x59fc('0x5b')]['id'];}_0x34933a['body'][_0x59fc('0x64')]=_0x34933a[_0x59fc('0x5b')][_0x59fc('0x64')]||_0x34933a[_0x59fc('0x65')]['id'];_0x62cc4a[_0x59fc('0x66')]['id']=_0x34933a[_0x59fc('0x5b')][_0x59fc('0x64')];return db[_0x59fc('0x3f')][_0x59fc('0x5c')]({'where':{'id':_0x34933a[_0x59fc('0x57')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x1a366d,null))['then'](function(_0x13f8b3){if(_0x13f8b3){_0x62cc4a[_0x59fc('0x2b')]=_0x13f8b3[_0x59fc('0x67')]({'plain':!![]});return db[_0x59fc('0x68')][_0x59fc('0x5c')]({'where':{'id':_0x13f8b3['OpenchannelInteractionId']}});}return null;})[_0x59fc('0x23')](handleEntityNotFound(_0x1a366d,null))[_0x59fc('0x23')](function(_0x464e8f){if(_0x464e8f){_0x62cc4a['interaction']=_0x464e8f[_0x59fc('0x67')]({'plain':!![]});interaction_log['info']('[OPENCHANNELMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x34933a['user']['id'],_0x34933a[_0x59fc('0x65')][_0x59fc('0x3d')],_0x34933a[_0x59fc('0x65')][_0x59fc('0x7f')],_0x62cc4a['interaction']['id'],_0x34933a[_0x59fc('0x5b')]?JSON[_0x59fc('0x80')](_0x34933a['body']):'null');return respondWithRpcPromise(_0x59fc('0x81'),_0x59fc('0x82'),_0x62cc4a);}return null;})[_0x59fc('0x23')](function(_0x500d39){var _0x564401='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x500d39[_0x59fc('0x2b')]['ContactId'];return db[_0x59fc('0x72')]['query'](_0x564401,{'type':db[_0x59fc('0x83')][_0x59fc('0x73')][_0x59fc('0x74')],'raw':!![]})['then'](function(_0x14de1d){return _0x14de1d;});})[_0x59fc('0x23')](function(_0x2c9cd4){if(_0x2c9cd4){_0x62cc4a[_0x59fc('0x2b')][_0x59fc('0x75')]=_0x2c9cd4[0x0];if(!_0x34933a[_0x59fc('0x5b')][_0x59fc('0x64')])return;return db[_0x59fc('0x76')]['find']({'where':{'id':_0x34933a[_0x59fc('0x5b')]['UserId'],'role':_0x59fc('0x66')},'attributes':['id',_0x59fc('0x3d'),_0x59fc('0x84'),_0x59fc('0x77'),_0x59fc('0x78')],'raw':!![]});}return null;})[_0x59fc('0x23')](function(_0x376025){if(!_0x376025)return null;_0x62cc4a[_0x59fc('0x2b')]['agent']=_0x376025;return _0x62cc4a;})[_0x59fc('0x23')](function(_0x68cd0){if(_0x68cd0){_0x68cd0[_0x59fc('0x2b')][_0x59fc('0x85')]=util[_0x59fc('0x62')]('SIP/%s',_0x34933a[_0x59fc('0x65')]['name']);_0x68cd0[_0x59fc('0x2b')][_0x59fc('0x7b')]=_0x62cc4a['channel'];_0x68cd0[_0x59fc('0x2b')][_0x59fc('0x7c')]=_0x62cc4a[_0x59fc('0x7b')];_0x68cd0['message']['event']=_0x59fc('0x38');respondWithRpcPromise(_0x59fc('0x7e'),'EventManager',{'event':_0x59fc('0x86'),'message':_0x68cd0[_0x59fc('0x2b')]},client9002);return _0x62cc4a;}return null;})[_0x59fc('0x23')](respondWithResult(_0x1a366d,null))[_0x59fc('0x2d')](handleError(_0x1a366d,null));};