924d80a3ba870b8569348239494ff03911735792
[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 _0x7dd7=['localhost','socket.io-emitter','register','request','info','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','VoiceQueue,\x20%s,\x20%s','result','catch','GetVoiceQueue','VoiceQueue','options','raw','where','limit','include','model','attributes','map','then','find','ShowVoiceQueue','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis'];(function(_0x27f533,_0x3f53d5){var _0x53f9ee=function(_0x5654ef){while(--_0x5654ef){_0x27f533['push'](_0x27f533['shift']());}};_0x53f9ee(++_0x3f53d5);}(_0x7dd7,0x112));var _0x77dd=function(_0x1d9aa0,_0x272488){_0x1d9aa0=_0x1d9aa0-0x0;var _0x226868=_0x7dd7[_0x1d9aa0];return _0x226868;};'use strict';var _=require(_0x77dd('0x0'));var util=require(_0x77dd('0x1'));var moment=require(_0x77dd('0x2'));var BPromise=require(_0x77dd('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x77dd('0x4'))['db'];var utils=require(_0x77dd('0x5'));var logger=require(_0x77dd('0x6'))(_0x77dd('0x7'));var config=require(_0x77dd('0x8'));var jayson=require(_0x77dd('0x9'));var client=jayson[_0x77dd('0xa')][_0x77dd('0xb')]({'port':0x232a});config[_0x77dd('0xc')]=_['defaults'](config['redis'],{'host':_0x77dd('0xd'),'port':0x18eb});var socket=require(_0x77dd('0xe'))(new Redis(config['redis']));require('./voiceQueue.socket')[_0x77dd('0xf')](socket);function respondWithRpcPromise(_0x4003b5,_0x4ba1e6,_0x7f5ec4){return new BPromise(function(_0x1597db,_0x267c9f){return client[_0x77dd('0x10')](_0x4003b5,_0x7f5ec4)['then'](function(_0x376c8d){logger[_0x77dd('0x11')]('VoiceQueue,\x20%s,\x20%s',_0x4ba1e6,_0x77dd('0x12'));logger[_0x77dd('0x13')](_0x77dd('0x14'),_0x4ba1e6,_0x77dd('0x12'),JSON[_0x77dd('0x15')](_0x376c8d));if(_0x376c8d[_0x77dd('0x16')]){if(_0x376c8d[_0x77dd('0x16')][_0x77dd('0x17')]===0x1f4){logger['error']('VoiceQueue,\x20%s,\x20%s',_0x4ba1e6,_0x376c8d[_0x77dd('0x16')][_0x77dd('0x18')]);return _0x267c9f(_0x376c8d['error']['message']);}logger[_0x77dd('0x16')](_0x77dd('0x19'),_0x4ba1e6,_0x376c8d[_0x77dd('0x16')]['message']);return _0x1597db(_0x376c8d[_0x77dd('0x16')][_0x77dd('0x18')]);}else{logger[_0x77dd('0x11')](_0x77dd('0x19'),_0x4ba1e6,_0x77dd('0x12'));_0x1597db(_0x376c8d[_0x77dd('0x1a')][_0x77dd('0x18')]);}})[_0x77dd('0x1b')](function(_0x2f9b5a){logger[_0x77dd('0x16')](_0x77dd('0x19'),_0x4ba1e6,_0x2f9b5a);_0x267c9f(_0x2f9b5a);});});}exports[_0x77dd('0x1c')]=function(_0x20d1eb){var _0x5235fa=this;return new Promise(function(_0x4751e4,_0x4bcda0){return db[_0x77dd('0x1d')]['findAll']({'raw':_0x20d1eb[_0x77dd('0x1e')]?_0x20d1eb[_0x77dd('0x1e')][_0x77dd('0x1f')]===undefined?!![]:![]:!![],'where':_0x20d1eb[_0x77dd('0x1e')]?_0x20d1eb[_0x77dd('0x1e')][_0x77dd('0x20')]||null:null,'attributes':_0x20d1eb['options']?_0x20d1eb['options']['attributes']||null:null,'limit':_0x20d1eb['options']?_0x20d1eb[_0x77dd('0x1e')][_0x77dd('0x21')]||null:null,'include':_0x20d1eb['options']?_0x20d1eb[_0x77dd('0x1e')][_0x77dd('0x22')]?_['map'](_0x20d1eb[_0x77dd('0x1e')][_0x77dd('0x22')],function(_0x50ee53){return{'model':db[_0x50ee53[_0x77dd('0x23')]],'as':_0x50ee53['as'],'attributes':_0x50ee53[_0x77dd('0x24')],'include':_0x50ee53[_0x77dd('0x22')]?_[_0x77dd('0x25')](_0x50ee53['include'],function(_0x5170d8){return{'model':db[_0x5170d8['model']],'as':_0x5170d8['as'],'attributes':_0x5170d8[_0x77dd('0x24')],'include':_0x5170d8[_0x77dd('0x22')]?_[_0x77dd('0x25')](_0x5170d8['include'],function(_0x590281){return{'model':db[_0x590281['model']],'as':_0x590281['as'],'attributes':_0x590281[_0x77dd('0x24')]};}):[]};}):[]};}):[]:[]})[_0x77dd('0x26')](function(_0x4584e7){logger[_0x77dd('0x11')](_0x77dd('0x1c'),_0x20d1eb);logger[_0x77dd('0x13')]('GetVoiceQueue',_0x20d1eb,JSON[_0x77dd('0x15')](_0x4584e7));_0x4751e4(_0x4584e7);})[_0x77dd('0x1b')](function(_0x2d8b3e){logger[_0x77dd('0x16')]('GetVoiceQueue',_0x2d8b3e[_0x77dd('0x18')],_0x20d1eb);_0x4bcda0(_0x5235fa['error'](0x1f4,_0x2d8b3e[_0x77dd('0x18')]));});});};exports['ShowVoiceQueue']=function(_0x31c720){var _0x1cd0b8=this;return new Promise(function(_0x4577b9,_0x3ca7c0){return db[_0x77dd('0x1d')][_0x77dd('0x27')]({'raw':_0x31c720[_0x77dd('0x1e')]?_0x31c720[_0x77dd('0x1e')][_0x77dd('0x1f')]===undefined?!![]:![]:!![],'where':_0x31c720['options']?_0x31c720[_0x77dd('0x1e')][_0x77dd('0x20')]||null:null,'attributes':_0x31c720['options']?_0x31c720[_0x77dd('0x1e')]['attributes']||null:null,'include':_0x31c720['options']?_0x31c720['options']['include']?_['map'](_0x31c720['options'][_0x77dd('0x22')],function(_0x449f94){return{'model':db[_0x449f94[_0x77dd('0x23')]],'as':_0x449f94['as'],'attributes':_0x449f94['attributes'],'include':_0x449f94[_0x77dd('0x22')]?_[_0x77dd('0x25')](_0x449f94[_0x77dd('0x22')],function(_0x2f2948){return{'model':db[_0x2f2948[_0x77dd('0x23')]],'as':_0x2f2948['as'],'attributes':_0x2f2948[_0x77dd('0x24')],'include':_0x2f2948[_0x77dd('0x22')]?_[_0x77dd('0x25')](_0x2f2948['include'],function(_0x481eda){return{'model':db[_0x481eda[_0x77dd('0x23')]],'as':_0x481eda['as'],'attributes':_0x481eda[_0x77dd('0x24')]};}):[]};}):[]};}):[]:[]})[_0x77dd('0x26')](function(_0x50369b){logger[_0x77dd('0x11')](_0x77dd('0x28'),_0x31c720);logger[_0x77dd('0x13')](_0x77dd('0x28'),_0x31c720,JSON[_0x77dd('0x15')](_0x50369b));_0x4577b9(_0x50369b);})[_0x77dd('0x1b')](function(_0x586be4){logger[_0x77dd('0x16')](_0x77dd('0x28'),_0x586be4[_0x77dd('0x18')],_0x31c720);_0x3ca7c0(_0x1cd0b8[_0x77dd('0x16')](0x1f4,_0x586be4['message']));});});};