Built motion from commit 7158bc59.|2.5.42
[motion2.git] / server / api / voiceQueue / voiceQueue.rpc.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 _0xa3a4=['request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','error','code','message','catch','GetVoiceQueue','VoiceQueue','options','raw','where','attributes','include','map','model','stringify','ShowVoiceQueue','find','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','http','redis','socket.io-emitter','./voiceQueue.socket','register','then','info','VoiceQueue,\x20%s,\x20%s'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xa3a4,0xa3));var _0x4a3a=function(_0x4f2632,_0x165ae5){_0x4f2632=_0x4f2632-0x0;var _0xadedc9=_0xa3a4[_0x4f2632];return _0xadedc9;};'use strict';var _=require(_0x4a3a('0x0'));var util=require(_0x4a3a('0x1'));var moment=require(_0x4a3a('0x2'));var BPromise=require('bluebird');var rs=require(_0x4a3a('0x3'));var fs=require('fs');var Redis=require(_0x4a3a('0x4'));var db=require(_0x4a3a('0x5'))['db'];var utils=require(_0x4a3a('0x6'));var logger=require('../../config/logger')(_0x4a3a('0x7'));var config=require('../../config/environment');var jayson=require(_0x4a3a('0x8'));var client=jayson['client'][_0x4a3a('0x9')]({'port':0x232a});config[_0x4a3a('0xa')]=_['defaults'](config[_0x4a3a('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x4a3a('0xb'))(new Redis(config['redis']));require(_0x4a3a('0xc'))[_0x4a3a('0xd')](socket);function respondWithRpcPromise(_0x3a6f80,_0x8ee31,_0x15b123){return new BPromise(function(_0x485ea3,_0x5d74c0){return client['request'](_0x3a6f80,_0x15b123)[_0x4a3a('0xe')](function(_0xc893a2){logger[_0x4a3a('0xf')](_0x4a3a('0x10'),_0x8ee31,_0x4a3a('0x11'));logger[_0x4a3a('0x12')](_0x4a3a('0x13'),_0x8ee31,_0x4a3a('0x11'),JSON['stringify'](_0xc893a2));if(_0xc893a2[_0x4a3a('0x14')]){if(_0xc893a2['error'][_0x4a3a('0x15')]===0x1f4){logger[_0x4a3a('0x14')]('VoiceQueue,\x20%s,\x20%s',_0x8ee31,_0xc893a2[_0x4a3a('0x14')][_0x4a3a('0x16')]);return _0x5d74c0(_0xc893a2['error'][_0x4a3a('0x16')]);}logger[_0x4a3a('0x14')](_0x4a3a('0x10'),_0x8ee31,_0xc893a2[_0x4a3a('0x14')]['message']);return _0x485ea3(_0xc893a2[_0x4a3a('0x14')][_0x4a3a('0x16')]);}else{logger['info']('VoiceQueue,\x20%s,\x20%s',_0x8ee31,_0x4a3a('0x11'));_0x485ea3(_0xc893a2['result'][_0x4a3a('0x16')]);}})[_0x4a3a('0x17')](function(_0x2a8048){logger[_0x4a3a('0x14')](_0x4a3a('0x10'),_0x8ee31,_0x2a8048);_0x5d74c0(_0x2a8048);});});}exports[_0x4a3a('0x18')]=function(_0x366a58){var _0x202537=this;return new Promise(function(_0x51f7e4,_0x5d60ec){return db[_0x4a3a('0x19')]['findAll']({'raw':_0x366a58[_0x4a3a('0x1a')]?_0x366a58[_0x4a3a('0x1a')][_0x4a3a('0x1b')]===undefined?!![]:![]:!![],'where':_0x366a58['options']?_0x366a58[_0x4a3a('0x1a')][_0x4a3a('0x1c')]||null:null,'attributes':_0x366a58[_0x4a3a('0x1a')]?_0x366a58[_0x4a3a('0x1a')][_0x4a3a('0x1d')]||null:null,'limit':_0x366a58[_0x4a3a('0x1a')]?_0x366a58[_0x4a3a('0x1a')]['limit']||null:null,'include':_0x366a58['options']?_0x366a58[_0x4a3a('0x1a')][_0x4a3a('0x1e')]?_[_0x4a3a('0x1f')](_0x366a58[_0x4a3a('0x1a')]['include'],function(_0x31ace8){return{'model':db[_0x31ace8['model']],'as':_0x31ace8['as'],'attributes':_0x31ace8[_0x4a3a('0x1d')],'include':_0x31ace8[_0x4a3a('0x1e')]?_[_0x4a3a('0x1f')](_0x31ace8['include'],function(_0x450ddd){return{'model':db[_0x450ddd[_0x4a3a('0x20')]],'as':_0x450ddd['as'],'attributes':_0x450ddd['attributes'],'include':_0x450ddd[_0x4a3a('0x1e')]?_[_0x4a3a('0x1f')](_0x450ddd[_0x4a3a('0x1e')],function(_0x535cc6){return{'model':db[_0x535cc6['model']],'as':_0x535cc6['as'],'attributes':_0x535cc6[_0x4a3a('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x4a3a('0xe')](function(_0x507b98){logger[_0x4a3a('0xf')]('GetVoiceQueue',_0x366a58);logger[_0x4a3a('0x12')](_0x4a3a('0x18'),_0x366a58,JSON[_0x4a3a('0x21')](_0x507b98));_0x51f7e4(_0x507b98);})[_0x4a3a('0x17')](function(_0x30fc48){logger[_0x4a3a('0x14')]('GetVoiceQueue',_0x30fc48['message'],_0x366a58);_0x5d60ec(_0x202537[_0x4a3a('0x14')](0x1f4,_0x30fc48[_0x4a3a('0x16')]));});});};exports[_0x4a3a('0x22')]=function(_0x1a2502){var _0x482565=this;return new Promise(function(_0x431650,_0x59a728){return db[_0x4a3a('0x19')][_0x4a3a('0x23')]({'raw':_0x1a2502[_0x4a3a('0x1a')]?_0x1a2502[_0x4a3a('0x1a')][_0x4a3a('0x1b')]===undefined?!![]:![]:!![],'where':_0x1a2502[_0x4a3a('0x1a')]?_0x1a2502['options'][_0x4a3a('0x1c')]||null:null,'attributes':_0x1a2502[_0x4a3a('0x1a')]?_0x1a2502[_0x4a3a('0x1a')][_0x4a3a('0x1d')]||null:null,'include':_0x1a2502['options']?_0x1a2502[_0x4a3a('0x1a')]['include']?_[_0x4a3a('0x1f')](_0x1a2502[_0x4a3a('0x1a')]['include'],function(_0x57c6f4){return{'model':db[_0x57c6f4[_0x4a3a('0x20')]],'as':_0x57c6f4['as'],'attributes':_0x57c6f4[_0x4a3a('0x1d')],'include':_0x57c6f4['include']?_[_0x4a3a('0x1f')](_0x57c6f4['include'],function(_0x41fb3b){return{'model':db[_0x41fb3b['model']],'as':_0x41fb3b['as'],'attributes':_0x41fb3b[_0x4a3a('0x1d')],'include':_0x41fb3b[_0x4a3a('0x1e')]?_[_0x4a3a('0x1f')](_0x41fb3b[_0x4a3a('0x1e')],function(_0x407ea1){return{'model':db[_0x407ea1[_0x4a3a('0x20')]],'as':_0x407ea1['as'],'attributes':_0x407ea1[_0x4a3a('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xe4549){logger[_0x4a3a('0xf')](_0x4a3a('0x22'),_0x1a2502);logger['debug'](_0x4a3a('0x22'),_0x1a2502,JSON[_0x4a3a('0x21')](_0xe4549));_0x431650(_0xe4549);})[_0x4a3a('0x17')](function(_0x2c1d6d){logger[_0x4a3a('0x14')](_0x4a3a('0x22'),_0x2c1d6d[_0x4a3a('0x16')],_0x1a2502);_0x59a728(_0x482565['error'](0x1f4,_0x2c1d6d[_0x4a3a('0x16')]));});});};