85f59cde6f5f92f8975219e9c1a6cfd267584681
[motion2.git] / server / api / rpc / rpc.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 _0xba6c=['client','http','then','error','message','result','catch','status','sendStatus','stack','name','send','isNil','rows','find','voiceChannels','VoiceChannels','voiceChannelMixMonitor','merge','params','VoiceChannelStopMixMonitor','query','voiceQueues','VoiceQueues','showVoiceQueues','voiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelRedirect','outbound','Outbound','outboundChannels','OutboundChannels','agents','Agents','agentCapacity','body','interaction','user','hasOwnProperty','INTERACTION','length','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','MemberReport','format','SIP/%s','interface','agent','internal','AgentCapacity','capacity','telephones','Telephones','trunks','campaigns','Campaigns','ChatQueues','mailQueues','MailQueues','showMailQueues','mailAccounts','openchannelQueues','showOpenchannelQueues','OpenchannelQueues','smsQueues','showSmsQueues','whatsappQueues','WhatsappQueues','showWhatsappQueues','showFaxQueues','FaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','chat','Website','Account','Queue','findOne','\x20Queue\x20not\x20found','Message','messageId','\x20Message\x20not\x20found','update','Interaction','queue','MessageId','InteractionId','TransferReport','create','Start','channel','User','Agent\x20not\x20found','From','agentTransferTimeout','*,*,*,*','bluebird','moment','lodash','util','../../config/logger','api','jayson/promise'];(function(_0x4f8d9c,_0x48cd7b){var _0x2400f5=function(_0x44ad8d){while(--_0x44ad8d){_0x4f8d9c['push'](_0x4f8d9c['shift']());}};_0x2400f5(++_0x48cd7b);}(_0xba6c,0x6e));var _0xcba6=function(_0x41382c,_0xc3ffd1){_0x41382c=_0x41382c-0x0;var _0x4da35b=_0xba6c[_0x41382c];return _0x4da35b;};'use strict';var BPromise=require(_0xcba6('0x0'));var moment=require(_0xcba6('0x1'));var _=require(_0xcba6('0x2'));var util=require(_0xcba6('0x3'));var db=require('../../mysqldb')['db'];var logger=require(_0xcba6('0x4'))(_0xcba6('0x5'));var jayson=require(_0xcba6('0x6'));var amiClient=jayson[_0xcba6('0x7')][_0xcba6('0x8')]({'port':0x232a});var mailClient=jayson[_0xcba6('0x7')]['http']({'port':0x232b});var routingClient=jayson[_0xcba6('0x7')][_0xcba6('0x8')]({'port':0x232c});function respondWithRpcPromise(_0x30886e,_0x52f935,_0x53f7d7){return new BPromise(function(_0xaafb23,_0x18c6dc){var _0x292dd6=_0x53f7d7?_0x53f7d7:amiClient;return _0x292dd6['request'](_0x30886e,_0x52f935)[_0xcba6('0x9')](function(_0x205847){if(_0x205847[_0xcba6('0xa')]){if(_0x205847[_0xcba6('0xa')]['code']===0x1f4){return _0x18c6dc(_0x205847[_0xcba6('0xa')][_0xcba6('0xb')]);}return _0xaafb23(_0x205847[_0xcba6('0xa')][_0xcba6('0xb')]);}else{_0xaafb23(_0x205847[_0xcba6('0xc')]);}})[_0xcba6('0xd')](function(_0x11e695){_0x18c6dc(_0x11e695);});});}function respondWithResult(_0x47d8b7,_0x2ee69e){_0x2ee69e=_0x2ee69e||0xc8;return function(_0x98a922){if(_0x98a922){return _0x47d8b7[_0xcba6('0xe')](_0x2ee69e)['json'](_0x98a922);}return _0x47d8b7[_0xcba6('0xf')](0x194);};}function handleError(_0x3c56d5,_0x1a031b){_0x1a031b=_0x1a031b||0x1f4;return function(_0x367f44){logger['error'](_0x367f44[_0xcba6('0x10')]);if(_0x367f44[_0xcba6('0x11')]){delete _0x367f44['name'];}_0x3c56d5[_0xcba6('0xe')](_0x1a031b)[_0xcba6('0x12')](_0x367f44);};}function findById(_0x31328b){return function(_0x58abef){if(!_['isNil'](_0x31328b)&&!_[_0xcba6('0x13')](_0x58abef)&&!_['isNil'](_0x58abef[_0xcba6('0x14')])){return _[_0xcba6('0x15')](_0x58abef[_0xcba6('0x14')],function(_0x1236db){return _0x1236db['id']==_0x31328b;});}return null;};}exports[_0xcba6('0x16')]=function(_0x4074a7,_0x1a805f){return respondWithRpcPromise(_0xcba6('0x17'),_0x4074a7['query'])['then'](respondWithResult(_0x1a805f,null))['catch'](handleError(_0x1a805f,null));};exports[_0xcba6('0x18')]=function(_0x17414f,_0xf4bf40){return respondWithRpcPromise('VoiceChannelMixMonitor',_[_0xcba6('0x19')](_0x17414f['query'],_0x17414f[_0xcba6('0x1a')]))[_0xcba6('0x9')](respondWithResult(_0xf4bf40,null))[_0xcba6('0xd')](handleError(_0xf4bf40,null));};exports['voiceChannelStopMixMonitor']=function(_0x332a6f,_0x2bfa98){return respondWithRpcPromise(_0xcba6('0x1b'),_[_0xcba6('0x19')](_0x332a6f[_0xcba6('0x1c')],_0x332a6f[_0xcba6('0x1a')]))[_0xcba6('0x9')](respondWithResult(_0x2bfa98,null))[_0xcba6('0xd')](handleError(_0x2bfa98,null));};exports[_0xcba6('0x1d')]=function(_0x10224e,_0xc56f09){return respondWithRpcPromise(_0xcba6('0x1e'),_0x10224e[_0xcba6('0x1c')])[_0xcba6('0x9')](respondWithResult(_0xc56f09,null))[_0xcba6('0xd')](handleError(_0xc56f09,null));};exports[_0xcba6('0x1f')]=function(_0x2e94e3,_0x3304d9){return respondWithRpcPromise('VoiceQueues',_0x2e94e3[_0xcba6('0x1c')])[_0xcba6('0x9')](findById(_0x2e94e3[_0xcba6('0x1a')]['id']))[_0xcba6('0x9')](respondWithResult(_0x3304d9,null))[_0xcba6('0xd')](handleError(_0x3304d9,null));};exports[_0xcba6('0x20')]=function(_0x27b7c5,_0x3d832e){return respondWithRpcPromise('VoiceQueuesPreview',_[_0xcba6('0x19')](_0x27b7c5[_0xcba6('0x1c')],_0x27b7c5[_0xcba6('0x1a')]))['then'](respondWithResult(_0x3d832e,null))['catch'](handleError(_0x3d832e,null));};exports[_0xcba6('0x21')]=function(_0x8f33a2,_0xb38f72){return respondWithRpcPromise(_0xcba6('0x22'),_0x8f33a2[_0xcba6('0x1c')])[_0xcba6('0x9')](respondWithResult(_0xb38f72,null))[_0xcba6('0xd')](handleError(_0xb38f72,null));};exports['voiceQueuesChannel']=function(_0xaa7a64,_0x51dd2d){return respondWithRpcPromise(_0xcba6('0x23'),_[_0xcba6('0x19')](_0xaa7a64[_0xcba6('0x1c')],_0xaa7a64['params']))[_0xcba6('0x9')](respondWithResult(_0x51dd2d,null))[_0xcba6('0xd')](handleError(_0x51dd2d,null));};exports[_0xcba6('0x24')]=function(_0x89c9b7,_0x46c141){return respondWithRpcPromise('VoiceQueuesChannelHangup',_[_0xcba6('0x19')](_0x89c9b7['query'],_0x89c9b7['params']))[_0xcba6('0x9')](respondWithResult(_0x46c141,null))[_0xcba6('0xd')](handleError(_0x46c141,null));};exports['voiceQueuesChannelRedirect']=function(_0x3bd490,_0x458728){return respondWithRpcPromise(_0xcba6('0x25'),_[_0xcba6('0x19')](_0x3bd490['query'],_0x3bd490['params']))[_0xcba6('0x9')](respondWithResult(_0x458728,null))['catch'](handleError(_0x458728,null));};exports[_0xcba6('0x26')]=function(_0x2e47cf,_0x128989){return respondWithRpcPromise(_0xcba6('0x27'),_0x2e47cf[_0xcba6('0x1c')])[_0xcba6('0x9')](respondWithResult(_0x128989,null))[_0xcba6('0xd')](handleError(_0x128989,null));};exports[_0xcba6('0x28')]=function(_0x3205c5,_0xf72608){return respondWithRpcPromise(_0xcba6('0x29'),_0x3205c5[_0xcba6('0x1c')])[_0xcba6('0x9')](respondWithResult(_0xf72608,null))[_0xcba6('0xd')](handleError(_0xf72608,null));};exports[_0xcba6('0x2a')]=function(_0x16326a,_0x1643c5){var _0x2b1cf9;return respondWithRpcPromise(_0xcba6('0x2b'),_0x16326a[_0xcba6('0x1c')])[_0xcba6('0x9')](function(_0x353f2d){_0x2b1cf9=_0x353f2d;return respondWithRpcPromise(_0xcba6('0x2b'),_0x16326a[_0xcba6('0x1c')],routingClient);})[_0xcba6('0x9')](function(_0xb688a){return _['merge']({},_0xb688a,_0x2b1cf9);})['then'](respondWithResult(_0x1643c5,null))[_0xcba6('0xd')](handleError(_0x1643c5,null));};exports[_0xcba6('0x2c')]=function(_0x428f19,_0x4ac9b8){if(_0x428f19[_0xcba6('0x2d')]&&_0x428f19[_0xcba6('0x2d')][_0xcba6('0x2e')]&&_0x428f19[_0xcba6('0x2f')]&&_0x428f19[_0xcba6('0x2f')][_0xcba6('0x11')]){for(var _0x417414 in _0x428f19[_0xcba6('0x2d')][_0xcba6('0x2e')]){if(_0x428f19[_0xcba6('0x2d')][_0xcba6('0x2e')][_0xcba6('0x30')](_0x417414)){db['MemberReport']['findAll']({'where':{'channel':_0x417414,'membername':_0x428f19[_0xcba6('0x2f')]['name'],'type':_0xcba6('0x31'),'exitAt':null,'uniqueid':_0x428f19['body'][_0xcba6('0x2e')][_0x417414]&&_0x428f19['body'][_0xcba6('0x2e')][_0x417414][_0xcba6('0x32')]?{'$notIn':_0x428f19['body'][_0xcba6('0x2e')][_0x417414]}:{'$ne':null}}})[_0xcba6('0x9')](function(_0x3e1e7f){var _0x1aa8aa=moment()['format'](_0xcba6('0x33'));for(var _0x487294=0x0,_0x17951c=_0x3e1e7f[_0xcba6('0x32')];_0x487294<_0x17951c;_0x487294+=0x1){_0x3e1e7f[_0x487294][_0xcba6('0x34')]({'exitAt':_0x1aa8aa});}});for(var _0x446141=0x0;_0x446141<_0x428f19[_0xcba6('0x2d')]['interaction'][_0x417414][_0xcba6('0x32')];_0x446141+=0x1){db[_0xcba6('0x35')]['findOrCreate']({'where':{'channel':_0x417414,'membername':_0x428f19[_0xcba6('0x2f')]['name'],'type':_0xcba6('0x31'),'uniqueid':_0x428f19[_0xcba6('0x2d')]['interaction'][_0x417414][_0x446141],'exitAt':null},'defaults':{'channel':_0x417414,'membername':_0x428f19['user'][_0xcba6('0x11')],'interface':_[_0xcba6('0x13')](_0x428f19[_0xcba6('0x2f')]['interface'])?util[_0xcba6('0x36')](_0xcba6('0x37'),_0x428f19[_0xcba6('0x2f')][_0xcba6('0x11')]):_0x428f19[_0xcba6('0x2f')][_0xcba6('0x38')],'type':'INTERACTION','enterAt':moment()[_0xcba6('0x36')](_0xcba6('0x33')),'role':_0xcba6('0x39'),'internal':_0x428f19['user'][_0xcba6('0x3a')],'uniqueid':_0x428f19[_0xcba6('0x2d')]['interaction'][_0x417414][_0x446141]}});}}}}return respondWithRpcPromise(_0xcba6('0x3b'),{'id':_0x428f19['params']['id'],'capacity':_0x428f19['body'][_0xcba6('0x3c')]},routingClient)[_0xcba6('0x9')](respondWithResult(_0x4ac9b8,null))[_0xcba6('0xd')](handleError(_0x4ac9b8,null));};exports[_0xcba6('0x3d')]=function(_0x282f54,_0x259ff2){return respondWithRpcPromise(_0xcba6('0x3e'),_0x282f54[_0xcba6('0x1c')])[_0xcba6('0x9')](respondWithResult(_0x259ff2,null))[_0xcba6('0xd')](handleError(_0x259ff2,null));};exports[_0xcba6('0x3f')]=function(_0x65ab05,_0x4667f1){return respondWithRpcPromise('Trunks',_0x65ab05[_0xcba6('0x1c')])[_0xcba6('0x9')](respondWithResult(_0x4667f1,null))[_0xcba6('0xd')](handleError(_0x4667f1,null));};exports[_0xcba6('0x40')]=function(_0x5dd2ac,_0x4bb3ac){return respondWithRpcPromise(_0xcba6('0x41'),_0x5dd2ac[_0xcba6('0x1c')])[_0xcba6('0x9')](respondWithResult(_0x4bb3ac,null))[_0xcba6('0xd')](handleError(_0x4bb3ac,null));};exports['chatQueues']=function(_0x45d7e3,_0x41aba5){return respondWithRpcPromise(_0xcba6('0x42'),_0x45d7e3[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](respondWithResult(_0x41aba5,null))[_0xcba6('0xd')](handleError(_0x41aba5,null));};exports['showChatQueues']=function(_0x44f9ca,_0x230783){return respondWithRpcPromise(_0xcba6('0x42'),_0x44f9ca['query'],routingClient)['then'](findById(_0x44f9ca[_0xcba6('0x1a')]['id']))['then'](respondWithResult(_0x230783,null))[_0xcba6('0xd')](handleError(_0x230783,null));};exports[_0xcba6('0x43')]=function(_0x1d27b2,_0x533ada){return respondWithRpcPromise(_0xcba6('0x44'),_0x1d27b2[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](respondWithResult(_0x533ada,null))[_0xcba6('0xd')](handleError(_0x533ada,null));};exports[_0xcba6('0x45')]=function(_0x3ccb6c,_0x14bf7c){return respondWithRpcPromise(_0xcba6('0x44'),_0x3ccb6c[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](findById(_0x3ccb6c[_0xcba6('0x1a')]['id']))[_0xcba6('0x9')](respondWithResult(_0x14bf7c,null))[_0xcba6('0xd')](handleError(_0x14bf7c,null));};exports[_0xcba6('0x46')]=function(_0x2fff35,_0x143526){return respondWithRpcPromise('MailAccounts',_0x2fff35[_0xcba6('0x1c')],mailClient)['then'](respondWithResult(_0x143526,null))['catch'](handleError(_0x143526,null));};exports[_0xcba6('0x47')]=function(_0x2bb19a,_0x32ee60){return respondWithRpcPromise('OpenchannelQueues',_0x2bb19a[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](respondWithResult(_0x32ee60,null))['catch'](handleError(_0x32ee60,null));};exports[_0xcba6('0x48')]=function(_0x42cc6c,_0x1fbb88){return respondWithRpcPromise(_0xcba6('0x49'),_0x42cc6c[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](findById(_0x42cc6c[_0xcba6('0x1a')]['id']))[_0xcba6('0x9')](respondWithResult(_0x1fbb88,null))[_0xcba6('0xd')](handleError(_0x1fbb88,null));};exports[_0xcba6('0x4a')]=function(_0x14434f,_0x1bd23d){return respondWithRpcPromise('SmsQueues',_0x14434f['query'],routingClient)['then'](respondWithResult(_0x1bd23d,null))[_0xcba6('0xd')](handleError(_0x1bd23d,null));};exports[_0xcba6('0x4b')]=function(_0x129fc4,_0x65675d){return respondWithRpcPromise('SmsQueues',_0x129fc4[_0xcba6('0x1c')],routingClient)['then'](findById(_0x129fc4[_0xcba6('0x1a')]['id']))[_0xcba6('0x9')](respondWithResult(_0x65675d,null))['catch'](handleError(_0x65675d,null));};exports[_0xcba6('0x4c')]=function(_0x21605b,_0x13093a){return respondWithRpcPromise(_0xcba6('0x4d'),_0x21605b['query'],routingClient)[_0xcba6('0x9')](respondWithResult(_0x13093a,null))[_0xcba6('0xd')](handleError(_0x13093a,null));};exports[_0xcba6('0x4e')]=function(_0x4d5763,_0x448de9){return respondWithRpcPromise('WhatsappQueues',_0x4d5763[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](findById(_0x4d5763[_0xcba6('0x1a')]['id']))[_0xcba6('0x9')](respondWithResult(_0x448de9,null))[_0xcba6('0xd')](handleError(_0x448de9,null));};exports['faxQueues']=function(_0x6886fa,_0x350fdf){return respondWithRpcPromise('FaxQueues',_0x6886fa[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](respondWithResult(_0x350fdf,null))[_0xcba6('0xd')](handleError(_0x350fdf,null));};exports[_0xcba6('0x4f')]=function(_0x15a8e2,_0x1b8533){return respondWithRpcPromise(_0xcba6('0x50'),_0x15a8e2[_0xcba6('0x1c')],routingClient)['then'](findById(_0x15a8e2[_0xcba6('0x1a')]['id']))['then'](respondWithResult(_0x1b8533,null))[_0xcba6('0xd')](handleError(_0x1b8533,null));};exports[_0xcba6('0x51')]=function(_0x498472,_0x2cd414){return respondWithRpcPromise(_0xcba6('0x52'),_0x498472[_0xcba6('0x1c')])['then'](respondWithResult(_0x2cd414,null))['catch'](handleError(_0x2cd414,null));};exports[_0xcba6('0x53')]=function(_0x50bd9d,_0x3744f9){return respondWithRpcPromise(_0xcba6('0x54'),_0x50bd9d[_0xcba6('0x1c')],routingClient)['then'](respondWithResult(_0x3744f9,null))[_0xcba6('0xd')](handleError(_0x3744f9,null));};exports[_0xcba6('0x55')]=function(_0x11ddca,_0x59bbc4){return respondWithRpcPromise('MailQueuesWaitingInteractions',_0x11ddca[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](respondWithResult(_0x59bbc4,null))['catch'](handleError(_0x59bbc4,null));};exports[_0xcba6('0x56')]=function(_0x3ac073,_0x2bb80f){return respondWithRpcPromise(_0xcba6('0x57'),_0x3ac073[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](respondWithResult(_0x2bb80f,null))['catch'](handleError(_0x2bb80f,null));};exports['smsQueuesWaitingInteractions']=function(_0x2e4e30,_0x1b9c00){return respondWithRpcPromise(_0xcba6('0x58'),_0x2e4e30[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](respondWithResult(_0x1b9c00,null))['catch'](handleError(_0x1b9c00,null));};exports[_0xcba6('0x59')]=function(_0x27e849,_0xff209d){return respondWithRpcPromise(_0xcba6('0x5a'),_0x27e849[_0xcba6('0x1c')],routingClient)[_0xcba6('0x9')](respondWithResult(_0xff209d,null))[_0xcba6('0xd')](handleError(_0xff209d,null));};exports['faxQueuesWaitingInteractions']=function(_0x36cbd4,_0x4c5e04){return respondWithRpcPromise(_0xcba6('0x5b'),_0x36cbd4[_0xcba6('0x1c')],routingClient)['then'](respondWithResult(_0x4c5e04,null))[_0xcba6('0xd')](handleError(_0x4c5e04,null));};exports[_0xcba6('0x5c')]=function(_0x3020ea){return function(_0x450fec,_0x1f107b){var _0x3e08fe,_0x5e0e8a;var _0x13cb07=_[_0xcba6('0x5d')](_0x3020ea);var _0x472dea=_0x3020ea===_0xcba6('0x5e')?_0xcba6('0x5f'):_0xcba6('0x60');return db[_0x13cb07+_0xcba6('0x61')][_0xcba6('0x62')]({'raw':!![],'where':{'id':_0x450fec['params']['id']}})[_0xcba6('0x9')](function(_0x8871c7){if(_[_0xcba6('0x13')](_0x8871c7)){throw new Error(_0x13cb07+_0xcba6('0x63'));}_0x3e08fe=_0x8871c7;return db[_0x13cb07+_0xcba6('0x64')][_0xcba6('0x62')]({'where':{'id':_0x450fec[_0xcba6('0x2d')][_0xcba6('0x65')]},'include':[{'model':db[_0x13cb07+'Interaction'],'as':'Interaction'},{'model':db[_0x13cb07+_0x472dea],'as':_0xcba6('0x60')}]});})['then'](function(_0x4331b3){if(_[_0xcba6('0x13')](_0x4331b3)){throw new Error(_0x13cb07+_0xcba6('0x66'));}_0x5e0e8a=_0x4331b3;return _0x4331b3[_0xcba6('0x67')]({'read':0x0,'readAt':null,'UserId':null});})[_0xcba6('0x9')](function(){var _0x57cfbb={'uniqueid':_0x3020ea+'.'+_0x5e0e8a['id']+'.'+_0x5e0e8a[_0xcba6('0x68')]['id'],'FromUserId':_0x450fec[_0xcba6('0x2f')]['id'],'type':_0xcba6('0x69')};_0x57cfbb[_0x13cb07+_0xcba6('0x6a')]=_0x5e0e8a['id'];_0x57cfbb[_0x13cb07+_0xcba6('0x6b')]=_0x5e0e8a[_0xcba6('0x68')]['id'];_0x57cfbb['From'+_0x13cb07+_0x472dea+'Id']=_0x5e0e8a[_0xcba6('0x60')]['id'];_0x57cfbb['To'+_0x13cb07+'QueueId']=_0x3e08fe['id'];return db[_0x13cb07+_0xcba6('0x6c')][_0xcba6('0x6d')](_0x57cfbb);})['then'](function(){return respondWithRpcPromise(_0xcba6('0x6e'),{'channel':_0x3020ea,'interaction':_0x5e0e8a['Interaction'],'message':_0x5e0e8a,'account':_0x5e0e8a[_0xcba6('0x60')],'applications':[{'id':0x0,'priority':0x1,'app':'queue','appdata':_0x3e08fe[_0xcba6('0x11')]+','+(_0x5e0e8a[_0xcba6('0x60')]['queueTransferTimeout']||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0xcba6('0x9')](respondWithResult(_0x1f107b,null))[_0xcba6('0xd')](handleError(_0x1f107b,null));};};exports['agentNotify']=function(_0x461832,_0x106dad){var _0x5a90a4,_0x3e8ea4;if(_[_0xcba6('0x13')](_0x461832[_0xcba6('0x2d')][_0xcba6('0x6f')])){throw new Error('Channel\x20field\x20is\x20mandatory');}var _0x25f047=_0x461832[_0xcba6('0x2d')][_0xcba6('0x6f')];var _0x2bda9e=_[_0xcba6('0x5d')](_0x25f047);var _0x488862=_0x25f047==='chat'?_0xcba6('0x5f'):'Account';return db[_0xcba6('0x70')]['findOne']({'raw':!![],'where':{'id':_0x461832[_0xcba6('0x1a')]['id'],'role':'agent'}})['then'](function(_0x39ac0a){if(_[_0xcba6('0x13')](_0x39ac0a)){throw new Error(_0xcba6('0x71'));}_0x5a90a4=_0x39ac0a;return db[_0x2bda9e+'Message'][_0xcba6('0x62')]({'where':{'id':_0x461832[_0xcba6('0x2d')][_0xcba6('0x65')]},'include':[{'model':db[_0x2bda9e+_0xcba6('0x68')],'as':_0xcba6('0x68')},{'model':db[_0x2bda9e+_0x488862],'as':_0xcba6('0x60')}]});})['then'](function(_0x32dc66){if(_['isNil'](_0x32dc66)){throw new Error(_0x2bda9e+_0xcba6('0x66'));}_0x3e8ea4=_0x32dc66;return _0x32dc66['update']({'read':0x0,'readAt':null,'UserId':null});})[_0xcba6('0x9')](function(){var _0x2e5203={'uniqueid':_0x25f047+'.'+_0x3e8ea4['id']+'.'+_0x3e8ea4[_0xcba6('0x68')]['id'],'FromUserId':_0x461832['user']['id'],'type':_0xcba6('0x69'),'ToUserId':_0x5a90a4['id']};_0x2e5203[_0x2bda9e+_0xcba6('0x6a')]=_0x3e8ea4['id'];_0x2e5203[_0x2bda9e+'InteractionId']=_0x3e8ea4['Interaction']['id'];_0x2e5203[_0xcba6('0x72')+_0x2bda9e+_0x488862+'Id']=_0x3e8ea4[_0xcba6('0x60')]['id'];return db[_0x2bda9e+_0xcba6('0x6c')][_0xcba6('0x6d')](_0x2e5203);})['then'](function(){return respondWithRpcPromise(_0xcba6('0x6e'),{'channel':_0x25f047,'interaction':_0x3e8ea4[_0xcba6('0x68')],'message':_0x3e8ea4,'account':_0x3e8ea4[_0xcba6('0x60')],'applications':[{'id':0x0,'priority':0x1,'app':'agent','appdata':_0x5a90a4[_0xcba6('0x11')]+','+(_0x3e8ea4[_0xcba6('0x60')][_0xcba6('0x73')]||0x12c),'interval':_0xcba6('0x74')}]},routingClient);})[_0xcba6('0x9')](respondWithResult(_0x106dad,null))[_0xcba6('0xd')](handleError(_0x106dad,null));};