d3e188b0f703cc29623c54f9eab0b71f2f73b9d2
[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 _0xf061=['ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','./voiceQueue.socket','request','then','VoiceQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','error','VoiceQueue,\x20%s,\x20%s','message','info','catch','GetVoiceQueue','VoiceQueue','options','raw','attributes','include','map','model','debug','find','ShowVoiceQueue','util','moment','randomstring'];(function(_0x50fb75,_0x379974){var _0x531b40=function(_0x28554b){while(--_0x28554b){_0x50fb75['push'](_0x50fb75['shift']());}};_0x531b40(++_0x379974);}(_0xf061,0x165));var _0x1f06=function(_0x5d7006,_0x4f7094){_0x5d7006=_0x5d7006-0x0;var _0x5ed777=_0xf061[_0x5d7006];return _0x5ed777;};'use strict';var _=require('lodash');var util=require(_0x1f06('0x0'));var moment=require(_0x1f06('0x1'));var BPromise=require('bluebird');var rs=require(_0x1f06('0x2'));var fs=require('fs');var Redis=require(_0x1f06('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x1f06('0x4'));var logger=require(_0x1f06('0x5'))(_0x1f06('0x6'));var config=require(_0x1f06('0x7'));var jayson=require(_0x1f06('0x8'));var client=jayson[_0x1f06('0x9')][_0x1f06('0xa')]({'port':0x232a});config['redis']=_['defaults'](config[_0x1f06('0xb')],{'host':_0x1f06('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x1f06('0xb')]));require(_0x1f06('0xd'))['register'](socket);function respondWithRpcPromise(_0x1acfe9,_0x61562f,_0x4f78a2){return new BPromise(function(_0x4a02df,_0xdd90bb){return client[_0x1f06('0xe')](_0x1acfe9,_0x4f78a2)[_0x1f06('0xf')](function(_0x163a5e){logger['info']('VoiceQueue,\x20%s,\x20%s',_0x61562f,'request\x20sent');logger['debug'](_0x1f06('0x10'),_0x61562f,_0x1f06('0x11'),JSON[_0x1f06('0x12')](_0x163a5e));if(_0x163a5e['error']){if(_0x163a5e['error'][_0x1f06('0x13')]===0x1f4){logger[_0x1f06('0x14')](_0x1f06('0x15'),_0x61562f,_0x163a5e[_0x1f06('0x14')][_0x1f06('0x16')]);return _0xdd90bb(_0x163a5e[_0x1f06('0x14')][_0x1f06('0x16')]);}logger[_0x1f06('0x14')](_0x1f06('0x15'),_0x61562f,_0x163a5e[_0x1f06('0x14')]['message']);return _0x4a02df(_0x163a5e[_0x1f06('0x14')][_0x1f06('0x16')]);}else{logger[_0x1f06('0x17')](_0x1f06('0x15'),_0x61562f,_0x1f06('0x11'));_0x4a02df(_0x163a5e['result']['message']);}})[_0x1f06('0x18')](function(_0xa8f94d){logger[_0x1f06('0x14')](_0x1f06('0x15'),_0x61562f,_0xa8f94d);_0xdd90bb(_0xa8f94d);});});}exports[_0x1f06('0x19')]=function(_0x3e257e){var _0x4ef8d1=this;return new Promise(function(_0x4440f9,_0x54b584){return db[_0x1f06('0x1a')]['findAll']({'raw':_0x3e257e['options']?_0x3e257e[_0x1f06('0x1b')][_0x1f06('0x1c')]===undefined?!![]:![]:!![],'where':_0x3e257e[_0x1f06('0x1b')]?_0x3e257e[_0x1f06('0x1b')]['where']||null:null,'attributes':_0x3e257e[_0x1f06('0x1b')]?_0x3e257e[_0x1f06('0x1b')][_0x1f06('0x1d')]||null:null,'limit':_0x3e257e[_0x1f06('0x1b')]?_0x3e257e['options']['limit']||null:null,'include':_0x3e257e[_0x1f06('0x1b')]?_0x3e257e[_0x1f06('0x1b')][_0x1f06('0x1e')]?_[_0x1f06('0x1f')](_0x3e257e[_0x1f06('0x1b')]['include'],function(_0x3bfae3){return{'model':db[_0x3bfae3[_0x1f06('0x20')]],'as':_0x3bfae3['as'],'attributes':_0x3bfae3[_0x1f06('0x1d')],'include':_0x3bfae3['include']?_[_0x1f06('0x1f')](_0x3bfae3[_0x1f06('0x1e')],function(_0x2dbc33){return{'model':db[_0x2dbc33[_0x1f06('0x20')]],'as':_0x2dbc33['as'],'attributes':_0x2dbc33['attributes'],'include':_0x2dbc33[_0x1f06('0x1e')]?_[_0x1f06('0x1f')](_0x2dbc33[_0x1f06('0x1e')],function(_0x3cbb76){return{'model':db[_0x3cbb76[_0x1f06('0x20')]],'as':_0x3cbb76['as'],'attributes':_0x3cbb76[_0x1f06('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x1f06('0xf')](function(_0x2cf229){logger[_0x1f06('0x17')](_0x1f06('0x19'),_0x3e257e);logger[_0x1f06('0x21')](_0x1f06('0x19'),_0x3e257e,JSON[_0x1f06('0x12')](_0x2cf229));_0x4440f9(_0x2cf229);})[_0x1f06('0x18')](function(_0xaec1d4){logger[_0x1f06('0x14')]('GetVoiceQueue',_0xaec1d4[_0x1f06('0x16')],_0x3e257e);_0x54b584(_0x4ef8d1[_0x1f06('0x14')](0x1f4,_0xaec1d4[_0x1f06('0x16')]));});});};exports['ShowVoiceQueue']=function(_0x236597){var _0xfe0c75=this;return new Promise(function(_0x1144ec,_0x199ee4){return db[_0x1f06('0x1a')][_0x1f06('0x22')]({'raw':_0x236597['options']?_0x236597['options'][_0x1f06('0x1c')]===undefined?!![]:![]:!![],'where':_0x236597[_0x1f06('0x1b')]?_0x236597['options']['where']||null:null,'attributes':_0x236597[_0x1f06('0x1b')]?_0x236597[_0x1f06('0x1b')][_0x1f06('0x1d')]||null:null,'include':_0x236597[_0x1f06('0x1b')]?_0x236597['options'][_0x1f06('0x1e')]?_['map'](_0x236597['options']['include'],function(_0x41995b){return{'model':db[_0x41995b['model']],'as':_0x41995b['as'],'attributes':_0x41995b[_0x1f06('0x1d')],'include':_0x41995b[_0x1f06('0x1e')]?_['map'](_0x41995b[_0x1f06('0x1e')],function(_0x3921b8){return{'model':db[_0x3921b8['model']],'as':_0x3921b8['as'],'attributes':_0x3921b8['attributes'],'include':_0x3921b8[_0x1f06('0x1e')]?_[_0x1f06('0x1f')](_0x3921b8[_0x1f06('0x1e')],function(_0x121246){return{'model':db[_0x121246['model']],'as':_0x121246['as'],'attributes':_0x121246[_0x1f06('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x1f06('0xf')](function(_0x22ff50){logger[_0x1f06('0x17')]('ShowVoiceQueue',_0x236597);logger[_0x1f06('0x21')](_0x1f06('0x23'),_0x236597,JSON[_0x1f06('0x12')](_0x22ff50));_0x1144ec(_0x22ff50);})[_0x1f06('0x18')](function(_0x4e60d4){logger[_0x1f06('0x14')](_0x1f06('0x23'),_0x4e60d4['message'],_0x236597);_0x199ee4(_0xfe0c75[_0x1f06('0x14')](0x1f4,_0x4e60d4[_0x1f06('0x16')]));});});};