Built motion from commit efa66e19.|2.6.22
[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 _0x23fc=['ShowVoiceQueue','find','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','redis','localhost','socket.io-emitter','./voiceQueue.socket','request','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetVoiceQueue','VoiceQueue','findAll','options','raw','where','attributes','limit','include','map','model','then'];(function(_0x2fb526,_0xace76b){var _0x7a7a50=function(_0x344538){while(--_0x344538){_0x2fb526['push'](_0x2fb526['shift']());}};_0x7a7a50(++_0xace76b);}(_0x23fc,0x1ca));var _0xc23f=function(_0xf34b0a,_0x11e116){_0xf34b0a=_0xf34b0a-0x0;var _0x5021e1=_0x23fc[_0xf34b0a];return _0x5021e1;};'use strict';var _=require('lodash');var util=require(_0xc23f('0x0'));var moment=require('moment');var BPromise=require(_0xc23f('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xc23f('0x2'));var db=require(_0xc23f('0x3'))['db'];var utils=require(_0xc23f('0x4'));var logger=require(_0xc23f('0x5'))('rpc');var config=require(_0xc23f('0x6'));var jayson=require(_0xc23f('0x7'));var client=jayson[_0xc23f('0x8')]['http']({'port':0x232a});config[_0xc23f('0x9')]=_['defaults'](config[_0xc23f('0x9')],{'host':_0xc23f('0xa'),'port':0x18eb});var socket=require(_0xc23f('0xb'))(new Redis(config[_0xc23f('0x9')]));require(_0xc23f('0xc'))['register'](socket);function respondWithRpcPromise(_0x634e95,_0x294e24,_0x1b8fc1){return new BPromise(function(_0x49057f,_0x1915be){return client[_0xc23f('0xd')](_0x634e95,_0x1b8fc1)['then'](function(_0x3e42dc){logger[_0xc23f('0xe')](_0xc23f('0xf'),_0x294e24,_0xc23f('0x10'));logger[_0xc23f('0x11')](_0xc23f('0x12'),_0x294e24,_0xc23f('0x10'),JSON[_0xc23f('0x13')](_0x3e42dc));if(_0x3e42dc[_0xc23f('0x14')]){if(_0x3e42dc[_0xc23f('0x14')][_0xc23f('0x15')]===0x1f4){logger['error'](_0xc23f('0xf'),_0x294e24,_0x3e42dc[_0xc23f('0x14')]['message']);return _0x1915be(_0x3e42dc['error'][_0xc23f('0x16')]);}logger['error'](_0xc23f('0xf'),_0x294e24,_0x3e42dc[_0xc23f('0x14')][_0xc23f('0x16')]);return _0x49057f(_0x3e42dc[_0xc23f('0x14')][_0xc23f('0x16')]);}else{logger['info'](_0xc23f('0xf'),_0x294e24,'request\x20sent');_0x49057f(_0x3e42dc['result']['message']);}})[_0xc23f('0x17')](function(_0x1332c9){logger['error'](_0xc23f('0xf'),_0x294e24,_0x1332c9);_0x1915be(_0x1332c9);});});}exports[_0xc23f('0x18')]=function(_0x26d9e4){var _0x1a8944=this;return new Promise(function(_0x6ae00f,_0x4af840){return db[_0xc23f('0x19')][_0xc23f('0x1a')]({'raw':_0x26d9e4['options']?_0x26d9e4[_0xc23f('0x1b')][_0xc23f('0x1c')]===undefined?!![]:![]:!![],'where':_0x26d9e4[_0xc23f('0x1b')]?_0x26d9e4['options'][_0xc23f('0x1d')]||null:null,'attributes':_0x26d9e4[_0xc23f('0x1b')]?_0x26d9e4[_0xc23f('0x1b')][_0xc23f('0x1e')]||null:null,'limit':_0x26d9e4[_0xc23f('0x1b')]?_0x26d9e4['options'][_0xc23f('0x1f')]||null:null,'include':_0x26d9e4[_0xc23f('0x1b')]?_0x26d9e4[_0xc23f('0x1b')][_0xc23f('0x20')]?_['map'](_0x26d9e4[_0xc23f('0x1b')][_0xc23f('0x20')],function(_0x91c49b){return{'model':db[_0x91c49b['model']],'as':_0x91c49b['as'],'attributes':_0x91c49b['attributes'],'include':_0x91c49b[_0xc23f('0x20')]?_[_0xc23f('0x21')](_0x91c49b['include'],function(_0x4faac0){return{'model':db[_0x4faac0[_0xc23f('0x22')]],'as':_0x4faac0['as'],'attributes':_0x4faac0[_0xc23f('0x1e')],'include':_0x4faac0[_0xc23f('0x20')]?_[_0xc23f('0x21')](_0x4faac0[_0xc23f('0x20')],function(_0x8dbf7d){return{'model':db[_0x8dbf7d['model']],'as':_0x8dbf7d['as'],'attributes':_0x8dbf7d['attributes']};}):[]};}):[]};}):[]:[]})[_0xc23f('0x23')](function(_0x1bd37e){logger[_0xc23f('0xe')](_0xc23f('0x18'),_0x26d9e4);logger[_0xc23f('0x11')]('GetVoiceQueue',_0x26d9e4,JSON[_0xc23f('0x13')](_0x1bd37e));_0x6ae00f(_0x1bd37e);})[_0xc23f('0x17')](function(_0x4da417){logger[_0xc23f('0x14')](_0xc23f('0x18'),_0x4da417[_0xc23f('0x16')],_0x26d9e4);_0x4af840(_0x1a8944[_0xc23f('0x14')](0x1f4,_0x4da417[_0xc23f('0x16')]));});});};exports[_0xc23f('0x24')]=function(_0x3900b4){var _0x59a116=this;return new Promise(function(_0x5b6d8d,_0x27e533){return db[_0xc23f('0x19')][_0xc23f('0x25')]({'raw':_0x3900b4[_0xc23f('0x1b')]?_0x3900b4[_0xc23f('0x1b')][_0xc23f('0x1c')]===undefined?!![]:![]:!![],'where':_0x3900b4[_0xc23f('0x1b')]?_0x3900b4['options'][_0xc23f('0x1d')]||null:null,'attributes':_0x3900b4[_0xc23f('0x1b')]?_0x3900b4['options'][_0xc23f('0x1e')]||null:null,'include':_0x3900b4[_0xc23f('0x1b')]?_0x3900b4[_0xc23f('0x1b')]['include']?_[_0xc23f('0x21')](_0x3900b4['options'][_0xc23f('0x20')],function(_0x3d4663){return{'model':db[_0x3d4663[_0xc23f('0x22')]],'as':_0x3d4663['as'],'attributes':_0x3d4663[_0xc23f('0x1e')],'include':_0x3d4663[_0xc23f('0x20')]?_[_0xc23f('0x21')](_0x3d4663[_0xc23f('0x20')],function(_0x216114){return{'model':db[_0x216114['model']],'as':_0x216114['as'],'attributes':_0x216114['attributes'],'include':_0x216114['include']?_['map'](_0x216114['include'],function(_0x3c95b4){return{'model':db[_0x3c95b4[_0xc23f('0x22')]],'as':_0x3c95b4['as'],'attributes':_0x3c95b4['attributes']};}):[]};}):[]};}):[]:[]})[_0xc23f('0x23')](function(_0x37182e){logger[_0xc23f('0xe')](_0xc23f('0x24'),_0x3900b4);logger[_0xc23f('0x11')](_0xc23f('0x24'),_0x3900b4,JSON[_0xc23f('0x13')](_0x37182e));_0x5b6d8d(_0x37182e);})['catch'](function(_0x4217c8){logger['error'](_0xc23f('0x24'),_0x4217c8[_0xc23f('0x16')],_0x3900b4);_0x27e533(_0x59a116[_0xc23f('0x14')](0x1f4,_0x4217c8[_0xc23f('0x16')]));});});};