54974c9dc388e2e422b1d4daa1b6399a2904664a
[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 _0xfc5c=['attributes','limit','include','model','map','ShowVoiceQueue','find','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','localhost','socket.io-emitter','./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceQueue','VoiceQueue','options','where'];(function(_0x36a398,_0x159cd3){var _0x566a2d=function(_0x5e5e97){while(--_0x5e5e97){_0x36a398['push'](_0x36a398['shift']());}};_0x566a2d(++_0x159cd3);}(_0xfc5c,0xab));var _0xcfc5=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xfc5c[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xcfc5('0x0'));var util=require(_0xcfc5('0x1'));var moment=require(_0xcfc5('0x2'));var BPromise=require(_0xcfc5('0x3'));var rs=require(_0xcfc5('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xcfc5('0x5'))['db'];var utils=require(_0xcfc5('0x6'));var logger=require(_0xcfc5('0x7'))(_0xcfc5('0x8'));var config=require(_0xcfc5('0x9'));var jayson=require(_0xcfc5('0xa'));var client=jayson[_0xcfc5('0xb')]['http']({'port':0x232a});config[_0xcfc5('0xc')]=_['defaults'](config[_0xcfc5('0xc')],{'host':_0xcfc5('0xd'),'port':0x18eb});var socket=require(_0xcfc5('0xe'))(new Redis(config[_0xcfc5('0xc')]));require(_0xcfc5('0xf'))[_0xcfc5('0x10')](socket);function respondWithRpcPromise(_0x17dc4c,_0x49236e,_0x16f537){return new BPromise(function(_0x131167,_0x140000){return client[_0xcfc5('0x11')](_0x17dc4c,_0x16f537)[_0xcfc5('0x12')](function(_0x1e9f30){logger[_0xcfc5('0x13')](_0xcfc5('0x14'),_0x49236e,_0xcfc5('0x15'));logger[_0xcfc5('0x16')](_0xcfc5('0x17'),_0x49236e,'request\x20sent',JSON[_0xcfc5('0x18')](_0x1e9f30));if(_0x1e9f30[_0xcfc5('0x19')]){if(_0x1e9f30[_0xcfc5('0x19')][_0xcfc5('0x1a')]===0x1f4){logger['error']('VoiceQueue,\x20%s,\x20%s',_0x49236e,_0x1e9f30[_0xcfc5('0x19')]['message']);return _0x140000(_0x1e9f30[_0xcfc5('0x19')]['message']);}logger['error'](_0xcfc5('0x14'),_0x49236e,_0x1e9f30[_0xcfc5('0x19')][_0xcfc5('0x1b')]);return _0x131167(_0x1e9f30[_0xcfc5('0x19')][_0xcfc5('0x1b')]);}else{logger['info'](_0xcfc5('0x14'),_0x49236e,_0xcfc5('0x15'));_0x131167(_0x1e9f30[_0xcfc5('0x1c')]['message']);}})[_0xcfc5('0x1d')](function(_0x449dee){logger[_0xcfc5('0x19')]('VoiceQueue,\x20%s,\x20%s',_0x49236e,_0x449dee);_0x140000(_0x449dee);});});}exports[_0xcfc5('0x1e')]=function(_0x40bf25){var _0x51d8c4=this;return new Promise(function(_0xce7830,_0x1469cf){return db[_0xcfc5('0x1f')]['findAll']({'raw':_0x40bf25[_0xcfc5('0x20')]?_0x40bf25[_0xcfc5('0x20')]['raw']===undefined?!![]:![]:!![],'where':_0x40bf25[_0xcfc5('0x20')]?_0x40bf25[_0xcfc5('0x20')][_0xcfc5('0x21')]||null:null,'attributes':_0x40bf25['options']?_0x40bf25[_0xcfc5('0x20')][_0xcfc5('0x22')]||null:null,'limit':_0x40bf25['options']?_0x40bf25[_0xcfc5('0x20')][_0xcfc5('0x23')]||null:null,'include':_0x40bf25['options']?_0x40bf25[_0xcfc5('0x20')]['include']?_['map'](_0x40bf25[_0xcfc5('0x20')][_0xcfc5('0x24')],function(_0x26c9a4){return{'model':db[_0x26c9a4[_0xcfc5('0x25')]],'as':_0x26c9a4['as'],'attributes':_0x26c9a4[_0xcfc5('0x22')],'include':_0x26c9a4[_0xcfc5('0x24')]?_[_0xcfc5('0x26')](_0x26c9a4[_0xcfc5('0x24')],function(_0x3fbaf0){return{'model':db[_0x3fbaf0[_0xcfc5('0x25')]],'as':_0x3fbaf0['as'],'attributes':_0x3fbaf0['attributes'],'include':_0x3fbaf0[_0xcfc5('0x24')]?_[_0xcfc5('0x26')](_0x3fbaf0[_0xcfc5('0x24')],function(_0x203ba1){return{'model':db[_0x203ba1[_0xcfc5('0x25')]],'as':_0x203ba1['as'],'attributes':_0x203ba1[_0xcfc5('0x22')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1fd749){logger[_0xcfc5('0x13')]('GetVoiceQueue',_0x40bf25);logger[_0xcfc5('0x16')](_0xcfc5('0x1e'),_0x40bf25,JSON[_0xcfc5('0x18')](_0x1fd749));_0xce7830(_0x1fd749);})['catch'](function(_0x20e86f){logger['error'](_0xcfc5('0x1e'),_0x20e86f[_0xcfc5('0x1b')],_0x40bf25);_0x1469cf(_0x51d8c4[_0xcfc5('0x19')](0x1f4,_0x20e86f[_0xcfc5('0x1b')]));});});};exports[_0xcfc5('0x27')]=function(_0xba76c6){var _0x52d56b=this;return new Promise(function(_0x35177f,_0x39fb8c){return db[_0xcfc5('0x1f')][_0xcfc5('0x28')]({'raw':_0xba76c6[_0xcfc5('0x20')]?_0xba76c6[_0xcfc5('0x20')]['raw']===undefined?!![]:![]:!![],'where':_0xba76c6[_0xcfc5('0x20')]?_0xba76c6[_0xcfc5('0x20')][_0xcfc5('0x21')]||null:null,'attributes':_0xba76c6['options']?_0xba76c6['options'][_0xcfc5('0x22')]||null:null,'include':_0xba76c6['options']?_0xba76c6[_0xcfc5('0x20')][_0xcfc5('0x24')]?_[_0xcfc5('0x26')](_0xba76c6[_0xcfc5('0x20')][_0xcfc5('0x24')],function(_0x1b5ecf){return{'model':db[_0x1b5ecf['model']],'as':_0x1b5ecf['as'],'attributes':_0x1b5ecf[_0xcfc5('0x22')],'include':_0x1b5ecf['include']?_[_0xcfc5('0x26')](_0x1b5ecf['include'],function(_0x41976b){return{'model':db[_0x41976b[_0xcfc5('0x25')]],'as':_0x41976b['as'],'attributes':_0x41976b[_0xcfc5('0x22')],'include':_0x41976b[_0xcfc5('0x24')]?_['map'](_0x41976b[_0xcfc5('0x24')],function(_0x3152ca){return{'model':db[_0x3152ca[_0xcfc5('0x25')]],'as':_0x3152ca['as'],'attributes':_0x3152ca[_0xcfc5('0x22')]};}):[]};}):[]};}):[]:[]})[_0xcfc5('0x12')](function(_0x349462){logger[_0xcfc5('0x13')](_0xcfc5('0x27'),_0xba76c6);logger['debug']('ShowVoiceQueue',_0xba76c6,JSON['stringify'](_0x349462));_0x35177f(_0x349462);})[_0xcfc5('0x1d')](function(_0x56f220){logger[_0xcfc5('0x19')](_0xcfc5('0x27'),_0x56f220[_0xcfc5('0x1b')],_0xba76c6);_0x39fb8c(_0x52d56b[_0xcfc5('0x19')](0x1f4,_0x56f220[_0xcfc5('0x1b')]));});});};