f91c2c2da8d2a77edcf9cf97c3f66b2848359982
[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 _0x8603=['VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','GetVoiceQueue','VoiceQueue','options','raw','where','limit','include','map','model','attributes','then','ShowVoiceQueue','find','lodash','moment','bluebird','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','defaults','redis','localhost','socket.io-emitter','./voiceQueue.socket','request','info'];(function(_0x27af45,_0x1b57aa){var _0x18df21=function(_0x4b7679){while(--_0x4b7679){_0x27af45['push'](_0x27af45['shift']());}};_0x18df21(++_0x1b57aa);}(_0x8603,0x163));var _0x3860=function(_0xd89bb6,_0x296bc9){_0xd89bb6=_0xd89bb6-0x0;var _0x15b345=_0x8603[_0xd89bb6];return _0x15b345;};'use strict';var _=require(_0x3860('0x0'));var util=require('util');var moment=require(_0x3860('0x1'));var BPromise=require(_0x3860('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3860('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x3860('0x4'));var logger=require(_0x3860('0x5'))('rpc');var config=require(_0x3860('0x6'));var jayson=require(_0x3860('0x7'));var client=jayson['client']['http']({'port':0x232a});config['redis']=_[_0x3860('0x8')](config[_0x3860('0x9')],{'host':_0x3860('0xa'),'port':0x18eb});var socket=require(_0x3860('0xb'))(new Redis(config[_0x3860('0x9')]));require(_0x3860('0xc'))['register'](socket);function respondWithRpcPromise(_0x30ea8f,_0x55d833,_0x12e9ec){return new BPromise(function(_0x368fde,_0x20a1ec){return client[_0x3860('0xd')](_0x30ea8f,_0x12e9ec)['then'](function(_0x317c20){logger[_0x3860('0xe')](_0x3860('0xf'),_0x55d833,_0x3860('0x10'));logger[_0x3860('0x11')]('VoiceQueue,\x20%s,\x20%s,\x20%s',_0x55d833,'request\x20sent',JSON[_0x3860('0x12')](_0x317c20));if(_0x317c20[_0x3860('0x13')]){if(_0x317c20[_0x3860('0x13')][_0x3860('0x14')]===0x1f4){logger[_0x3860('0x13')](_0x3860('0xf'),_0x55d833,_0x317c20[_0x3860('0x13')]['message']);return _0x20a1ec(_0x317c20[_0x3860('0x13')][_0x3860('0x15')]);}logger[_0x3860('0x13')](_0x3860('0xf'),_0x55d833,_0x317c20[_0x3860('0x13')][_0x3860('0x15')]);return _0x368fde(_0x317c20[_0x3860('0x13')][_0x3860('0x15')]);}else{logger['info']('VoiceQueue,\x20%s,\x20%s',_0x55d833,_0x3860('0x10'));_0x368fde(_0x317c20[_0x3860('0x16')][_0x3860('0x15')]);}})[_0x3860('0x17')](function(_0x1c571a){logger['error'](_0x3860('0xf'),_0x55d833,_0x1c571a);_0x20a1ec(_0x1c571a);});});}exports[_0x3860('0x18')]=function(_0x133a17){var _0x45d2cf=this;return new Promise(function(_0x647158,_0x448e07){return db[_0x3860('0x19')]['findAll']({'raw':_0x133a17[_0x3860('0x1a')]?_0x133a17[_0x3860('0x1a')][_0x3860('0x1b')]===undefined?!![]:![]:!![],'where':_0x133a17[_0x3860('0x1a')]?_0x133a17[_0x3860('0x1a')][_0x3860('0x1c')]||null:null,'attributes':_0x133a17['options']?_0x133a17[_0x3860('0x1a')]['attributes']||null:null,'limit':_0x133a17[_0x3860('0x1a')]?_0x133a17[_0x3860('0x1a')][_0x3860('0x1d')]||null:null,'include':_0x133a17[_0x3860('0x1a')]?_0x133a17[_0x3860('0x1a')][_0x3860('0x1e')]?_[_0x3860('0x1f')](_0x133a17[_0x3860('0x1a')]['include'],function(_0x1bbbf6){return{'model':db[_0x1bbbf6[_0x3860('0x20')]],'as':_0x1bbbf6['as'],'attributes':_0x1bbbf6[_0x3860('0x21')],'include':_0x1bbbf6[_0x3860('0x1e')]?_[_0x3860('0x1f')](_0x1bbbf6['include'],function(_0x190209){return{'model':db[_0x190209[_0x3860('0x20')]],'as':_0x190209['as'],'attributes':_0x190209[_0x3860('0x21')],'include':_0x190209['include']?_[_0x3860('0x1f')](_0x190209['include'],function(_0x5e3ba3){return{'model':db[_0x5e3ba3[_0x3860('0x20')]],'as':_0x5e3ba3['as'],'attributes':_0x5e3ba3[_0x3860('0x21')]};}):[]};}):[]};}):[]:[]})[_0x3860('0x22')](function(_0xac6ce5){logger[_0x3860('0xe')](_0x3860('0x18'),_0x133a17);logger[_0x3860('0x11')]('GetVoiceQueue',_0x133a17,JSON['stringify'](_0xac6ce5));_0x647158(_0xac6ce5);})[_0x3860('0x17')](function(_0x1bed63){logger[_0x3860('0x13')](_0x3860('0x18'),_0x1bed63[_0x3860('0x15')],_0x133a17);_0x448e07(_0x45d2cf[_0x3860('0x13')](0x1f4,_0x1bed63[_0x3860('0x15')]));});});};exports[_0x3860('0x23')]=function(_0x3de612){var _0x224a8f=this;return new Promise(function(_0x157b84,_0x2ad160){return db[_0x3860('0x19')][_0x3860('0x24')]({'raw':_0x3de612[_0x3860('0x1a')]?_0x3de612[_0x3860('0x1a')][_0x3860('0x1b')]===undefined?!![]:![]:!![],'where':_0x3de612[_0x3860('0x1a')]?_0x3de612[_0x3860('0x1a')]['where']||null:null,'attributes':_0x3de612[_0x3860('0x1a')]?_0x3de612[_0x3860('0x1a')][_0x3860('0x21')]||null:null,'include':_0x3de612['options']?_0x3de612[_0x3860('0x1a')][_0x3860('0x1e')]?_['map'](_0x3de612[_0x3860('0x1a')][_0x3860('0x1e')],function(_0x2a3c60){return{'model':db[_0x2a3c60[_0x3860('0x20')]],'as':_0x2a3c60['as'],'attributes':_0x2a3c60[_0x3860('0x21')],'include':_0x2a3c60['include']?_[_0x3860('0x1f')](_0x2a3c60[_0x3860('0x1e')],function(_0x137441){return{'model':db[_0x137441[_0x3860('0x20')]],'as':_0x137441['as'],'attributes':_0x137441['attributes'],'include':_0x137441[_0x3860('0x1e')]?_[_0x3860('0x1f')](_0x137441[_0x3860('0x1e')],function(_0x200510){return{'model':db[_0x200510[_0x3860('0x20')]],'as':_0x200510['as'],'attributes':_0x200510[_0x3860('0x21')]};}):[]};}):[]};}):[]:[]})[_0x3860('0x22')](function(_0x49f62e){logger[_0x3860('0xe')]('ShowVoiceQueue',_0x3de612);logger['debug'](_0x3860('0x23'),_0x3de612,JSON[_0x3860('0x12')](_0x49f62e));_0x157b84(_0x49f62e);})[_0x3860('0x17')](function(_0x7bf0bb){logger[_0x3860('0x13')](_0x3860('0x23'),_0x7bf0bb[_0x3860('0x15')],_0x3de612);_0x2ad160(_0x224a8f[_0x3860('0x13')](0x1f4,_0x7bf0bb[_0x3860('0x15')]));});});};