6cd77a30347dd6e9f43bbd93b944b3f88b582d69
[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 _0xcc72=['message','result','catch','GetVoiceQueue','VoiceQueue','findAll','options','raw','where','limit','map','include','model','attributes','ShowVoiceQueue','find','lodash','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code'];(function(_0x25c326,_0x250137){var _0x762452=function(_0x50ce5e){while(--_0x50ce5e){_0x25c326['push'](_0x25c326['shift']());}};_0x762452(++_0x250137);}(_0xcc72,0x158));var _0x2cc7=function(_0xc332fe,_0x12735e){_0xc332fe=_0xc332fe-0x0;var _0x384c91=_0xcc72[_0xc332fe];return _0x384c91;};'use strict';var _=require(_0x2cc7('0x0'));var util=require(_0x2cc7('0x1'));var moment=require('moment');var BPromise=require(_0x2cc7('0x2'));var rs=require(_0x2cc7('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2cc7('0x4'))['db'];var utils=require(_0x2cc7('0x5'));var logger=require(_0x2cc7('0x6'))('rpc');var config=require(_0x2cc7('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x2cc7('0x8')]['http']({'port':0x232a});config[_0x2cc7('0x9')]=_[_0x2cc7('0xa')](config[_0x2cc7('0x9')],{'host':_0x2cc7('0xb'),'port':0x18eb});var socket=require(_0x2cc7('0xc'))(new Redis(config[_0x2cc7('0x9')]));require(_0x2cc7('0xd'))[_0x2cc7('0xe')](socket);function respondWithRpcPromise(_0x385471,_0x139f09,_0x1cf2ab){return new BPromise(function(_0x458e76,_0x30896f){return client[_0x2cc7('0xf')](_0x385471,_0x1cf2ab)[_0x2cc7('0x10')](function(_0x70fee){logger[_0x2cc7('0x11')](_0x2cc7('0x12'),_0x139f09,'request\x20sent');logger[_0x2cc7('0x13')](_0x2cc7('0x14'),_0x139f09,_0x2cc7('0x15'),JSON[_0x2cc7('0x16')](_0x70fee));if(_0x70fee['error']){if(_0x70fee[_0x2cc7('0x17')][_0x2cc7('0x18')]===0x1f4){logger[_0x2cc7('0x17')]('VoiceQueue,\x20%s,\x20%s',_0x139f09,_0x70fee[_0x2cc7('0x17')][_0x2cc7('0x19')]);return _0x30896f(_0x70fee['error'][_0x2cc7('0x19')]);}logger[_0x2cc7('0x17')]('VoiceQueue,\x20%s,\x20%s',_0x139f09,_0x70fee[_0x2cc7('0x17')][_0x2cc7('0x19')]);return _0x458e76(_0x70fee['error'][_0x2cc7('0x19')]);}else{logger[_0x2cc7('0x11')](_0x2cc7('0x12'),_0x139f09,_0x2cc7('0x15'));_0x458e76(_0x70fee[_0x2cc7('0x1a')]['message']);}})[_0x2cc7('0x1b')](function(_0x40d495){logger[_0x2cc7('0x17')](_0x2cc7('0x12'),_0x139f09,_0x40d495);_0x30896f(_0x40d495);});});}exports[_0x2cc7('0x1c')]=function(_0x116bf9){var _0x985826=this;return new Promise(function(_0x5a54f5,_0x464cf2){return db[_0x2cc7('0x1d')][_0x2cc7('0x1e')]({'raw':_0x116bf9[_0x2cc7('0x1f')]?_0x116bf9[_0x2cc7('0x1f')][_0x2cc7('0x20')]===undefined?!![]:![]:!![],'where':_0x116bf9['options']?_0x116bf9[_0x2cc7('0x1f')][_0x2cc7('0x21')]||null:null,'attributes':_0x116bf9[_0x2cc7('0x1f')]?_0x116bf9['options']['attributes']||null:null,'limit':_0x116bf9[_0x2cc7('0x1f')]?_0x116bf9[_0x2cc7('0x1f')][_0x2cc7('0x22')]||null:null,'include':_0x116bf9['options']?_0x116bf9[_0x2cc7('0x1f')]['include']?_[_0x2cc7('0x23')](_0x116bf9[_0x2cc7('0x1f')][_0x2cc7('0x24')],function(_0x3c072e){return{'model':db[_0x3c072e[_0x2cc7('0x25')]],'as':_0x3c072e['as'],'attributes':_0x3c072e[_0x2cc7('0x26')],'include':_0x3c072e['include']?_['map'](_0x3c072e[_0x2cc7('0x24')],function(_0x113740){return{'model':db[_0x113740[_0x2cc7('0x25')]],'as':_0x113740['as'],'attributes':_0x113740[_0x2cc7('0x26')],'include':_0x113740[_0x2cc7('0x24')]?_[_0x2cc7('0x23')](_0x113740[_0x2cc7('0x24')],function(_0x234702){return{'model':db[_0x234702['model']],'as':_0x234702['as'],'attributes':_0x234702[_0x2cc7('0x26')]};}):[]};}):[]};}):[]:[]})[_0x2cc7('0x10')](function(_0x69063){logger['info']('GetVoiceQueue',_0x116bf9);logger['debug'](_0x2cc7('0x1c'),_0x116bf9,JSON[_0x2cc7('0x16')](_0x69063));_0x5a54f5(_0x69063);})[_0x2cc7('0x1b')](function(_0x2bab90){logger[_0x2cc7('0x17')](_0x2cc7('0x1c'),_0x2bab90[_0x2cc7('0x19')],_0x116bf9);_0x464cf2(_0x985826[_0x2cc7('0x17')](0x1f4,_0x2bab90[_0x2cc7('0x19')]));});});};exports[_0x2cc7('0x27')]=function(_0xfb1655){var _0x5e52c7=this;return new Promise(function(_0x6724f8,_0x3a7a44){return db['VoiceQueue'][_0x2cc7('0x28')]({'raw':_0xfb1655[_0x2cc7('0x1f')]?_0xfb1655[_0x2cc7('0x1f')][_0x2cc7('0x20')]===undefined?!![]:![]:!![],'where':_0xfb1655[_0x2cc7('0x1f')]?_0xfb1655[_0x2cc7('0x1f')][_0x2cc7('0x21')]||null:null,'attributes':_0xfb1655[_0x2cc7('0x1f')]?_0xfb1655[_0x2cc7('0x1f')][_0x2cc7('0x26')]||null:null,'include':_0xfb1655[_0x2cc7('0x1f')]?_0xfb1655['options'][_0x2cc7('0x24')]?_[_0x2cc7('0x23')](_0xfb1655[_0x2cc7('0x1f')]['include'],function(_0x2fc351){return{'model':db[_0x2fc351[_0x2cc7('0x25')]],'as':_0x2fc351['as'],'attributes':_0x2fc351['attributes'],'include':_0x2fc351[_0x2cc7('0x24')]?_[_0x2cc7('0x23')](_0x2fc351[_0x2cc7('0x24')],function(_0x1b7347){return{'model':db[_0x1b7347['model']],'as':_0x1b7347['as'],'attributes':_0x1b7347[_0x2cc7('0x26')],'include':_0x1b7347[_0x2cc7('0x24')]?_[_0x2cc7('0x23')](_0x1b7347[_0x2cc7('0x24')],function(_0x99e80d){return{'model':db[_0x99e80d[_0x2cc7('0x25')]],'as':_0x99e80d['as'],'attributes':_0x99e80d[_0x2cc7('0x26')]};}):[]};}):[]};}):[]:[]})[_0x2cc7('0x10')](function(_0x50e00b){logger[_0x2cc7('0x11')](_0x2cc7('0x27'),_0xfb1655);logger[_0x2cc7('0x13')](_0x2cc7('0x27'),_0xfb1655,JSON[_0x2cc7('0x16')](_0x50e00b));_0x6724f8(_0x50e00b);})['catch'](function(_0x3b35e1){logger[_0x2cc7('0x17')]('ShowVoiceQueue',_0x3b35e1[_0x2cc7('0x19')],_0xfb1655);_0x3a7a44(_0x5e52c7[_0x2cc7('0x17')](0x1f4,_0x3b35e1['message']));});});};