Built motion from commit f25620e4.|2.6.30
[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 _0xf6c4=['VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','GetVoiceQueue','VoiceQueue','options','raw','where','attributes','limit','include','model','map','ShowVoiceQueue','find','lodash','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./voiceQueue.socket','register','request','then','info'];(function(_0x4bed75,_0x211cc7){var _0x2dd8e8=function(_0x6369c7){while(--_0x6369c7){_0x4bed75['push'](_0x4bed75['shift']());}};_0x2dd8e8(++_0x211cc7);}(_0xf6c4,0x144));var _0x4f6c=function(_0x1753c4,_0x10125b){_0x1753c4=_0x1753c4-0x0;var _0x45a679=_0xf6c4[_0x1753c4];return _0x45a679;};'use strict';var _=require(_0x4f6c('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x4f6c('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4f6c('0x2'));var db=require(_0x4f6c('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x4f6c('0x4'))(_0x4f6c('0x5'));var config=require(_0x4f6c('0x6'));var jayson=require(_0x4f6c('0x7'));var client=jayson[_0x4f6c('0x8')][_0x4f6c('0x9')]({'port':0x232a});config[_0x4f6c('0xa')]=_[_0x4f6c('0xb')](config['redis'],{'host':_0x4f6c('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x4f6c('0xd'))[_0x4f6c('0xe')](socket);function respondWithRpcPromise(_0x2ef5b1,_0x19c5dd,_0x34cfbd){return new BPromise(function(_0x13b440,_0x590af4){return client[_0x4f6c('0xf')](_0x2ef5b1,_0x34cfbd)[_0x4f6c('0x10')](function(_0x4f9fb8){logger[_0x4f6c('0x11')](_0x4f6c('0x12'),_0x19c5dd,_0x4f6c('0x13'));logger[_0x4f6c('0x14')]('VoiceQueue,\x20%s,\x20%s,\x20%s',_0x19c5dd,'request\x20sent',JSON[_0x4f6c('0x15')](_0x4f9fb8));if(_0x4f9fb8[_0x4f6c('0x16')]){if(_0x4f9fb8[_0x4f6c('0x16')]['code']===0x1f4){logger[_0x4f6c('0x16')]('VoiceQueue,\x20%s,\x20%s',_0x19c5dd,_0x4f9fb8[_0x4f6c('0x16')][_0x4f6c('0x17')]);return _0x590af4(_0x4f9fb8['error'][_0x4f6c('0x17')]);}logger[_0x4f6c('0x16')]('VoiceQueue,\x20%s,\x20%s',_0x19c5dd,_0x4f9fb8['error'][_0x4f6c('0x17')]);return _0x13b440(_0x4f9fb8[_0x4f6c('0x16')]['message']);}else{logger[_0x4f6c('0x11')]('VoiceQueue,\x20%s,\x20%s',_0x19c5dd,'request\x20sent');_0x13b440(_0x4f9fb8[_0x4f6c('0x18')][_0x4f6c('0x17')]);}})[_0x4f6c('0x19')](function(_0x3fd067){logger[_0x4f6c('0x16')]('VoiceQueue,\x20%s,\x20%s',_0x19c5dd,_0x3fd067);_0x590af4(_0x3fd067);});});}exports[_0x4f6c('0x1a')]=function(_0x52fd2d){var _0x360051=this;return new Promise(function(_0x33d392,_0x59f46d){return db[_0x4f6c('0x1b')]['findAll']({'raw':_0x52fd2d[_0x4f6c('0x1c')]?_0x52fd2d[_0x4f6c('0x1c')][_0x4f6c('0x1d')]===undefined?!![]:![]:!![],'where':_0x52fd2d[_0x4f6c('0x1c')]?_0x52fd2d[_0x4f6c('0x1c')][_0x4f6c('0x1e')]||null:null,'attributes':_0x52fd2d[_0x4f6c('0x1c')]?_0x52fd2d['options'][_0x4f6c('0x1f')]||null:null,'limit':_0x52fd2d[_0x4f6c('0x1c')]?_0x52fd2d[_0x4f6c('0x1c')][_0x4f6c('0x20')]||null:null,'include':_0x52fd2d[_0x4f6c('0x1c')]?_0x52fd2d['options'][_0x4f6c('0x21')]?_['map'](_0x52fd2d[_0x4f6c('0x1c')][_0x4f6c('0x21')],function(_0x45059b){return{'model':db[_0x45059b[_0x4f6c('0x22')]],'as':_0x45059b['as'],'attributes':_0x45059b['attributes'],'include':_0x45059b[_0x4f6c('0x21')]?_[_0x4f6c('0x23')](_0x45059b[_0x4f6c('0x21')],function(_0x6c6773){return{'model':db[_0x6c6773[_0x4f6c('0x22')]],'as':_0x6c6773['as'],'attributes':_0x6c6773[_0x4f6c('0x1f')],'include':_0x6c6773[_0x4f6c('0x21')]?_[_0x4f6c('0x23')](_0x6c6773[_0x4f6c('0x21')],function(_0x49a2fa){return{'model':db[_0x49a2fa['model']],'as':_0x49a2fa['as'],'attributes':_0x49a2fa[_0x4f6c('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xc9ec32){logger[_0x4f6c('0x11')](_0x4f6c('0x1a'),_0x52fd2d);logger['debug'](_0x4f6c('0x1a'),_0x52fd2d,JSON[_0x4f6c('0x15')](_0xc9ec32));_0x33d392(_0xc9ec32);})['catch'](function(_0x312eb9){logger[_0x4f6c('0x16')]('GetVoiceQueue',_0x312eb9[_0x4f6c('0x17')],_0x52fd2d);_0x59f46d(_0x360051[_0x4f6c('0x16')](0x1f4,_0x312eb9[_0x4f6c('0x17')]));});});};exports[_0x4f6c('0x24')]=function(_0x439a07){var _0x2ccd37=this;return new Promise(function(_0x404264,_0x43f016){return db[_0x4f6c('0x1b')][_0x4f6c('0x25')]({'raw':_0x439a07['options']?_0x439a07[_0x4f6c('0x1c')][_0x4f6c('0x1d')]===undefined?!![]:![]:!![],'where':_0x439a07[_0x4f6c('0x1c')]?_0x439a07[_0x4f6c('0x1c')][_0x4f6c('0x1e')]||null:null,'attributes':_0x439a07[_0x4f6c('0x1c')]?_0x439a07[_0x4f6c('0x1c')]['attributes']||null:null,'include':_0x439a07['options']?_0x439a07['options'][_0x4f6c('0x21')]?_[_0x4f6c('0x23')](_0x439a07[_0x4f6c('0x1c')][_0x4f6c('0x21')],function(_0x370995){return{'model':db[_0x370995[_0x4f6c('0x22')]],'as':_0x370995['as'],'attributes':_0x370995[_0x4f6c('0x1f')],'include':_0x370995[_0x4f6c('0x21')]?_[_0x4f6c('0x23')](_0x370995[_0x4f6c('0x21')],function(_0x38ccb0){return{'model':db[_0x38ccb0['model']],'as':_0x38ccb0['as'],'attributes':_0x38ccb0[_0x4f6c('0x1f')],'include':_0x38ccb0[_0x4f6c('0x21')]?_[_0x4f6c('0x23')](_0x38ccb0[_0x4f6c('0x21')],function(_0x3c1f66){return{'model':db[_0x3c1f66[_0x4f6c('0x22')]],'as':_0x3c1f66['as'],'attributes':_0x3c1f66['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x3ec288){logger['info'](_0x4f6c('0x24'),_0x439a07);logger[_0x4f6c('0x14')](_0x4f6c('0x24'),_0x439a07,JSON[_0x4f6c('0x15')](_0x3ec288));_0x404264(_0x3ec288);})[_0x4f6c('0x19')](function(_0xaa0bf2){logger[_0x4f6c('0x16')](_0x4f6c('0x24'),_0xaa0bf2[_0x4f6c('0x17')],_0x439a07);_0x43f016(_0x2ccd37[_0x4f6c('0x16')](0x1f4,_0xaa0bf2['message']));});});};