6b690d920ae67120786cb8a4ccad6bec49f92e54
[motion2.git] / server / api / userVoiceQueueRt / userVoiceQueueRt.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 _0x88fc=['info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','options','raw','where','sequelize','COUNT','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','client','http','redis','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','then'];(function(_0x4fd767,_0x25cdca){var _0x48e469=function(_0xec9baa){while(--_0xec9baa){_0x4fd767['push'](_0x4fd767['shift']());}};_0x48e469(++_0x25cdca);}(_0x88fc,0x100));var _0xc88f=function(_0xf0f683,_0x28fce1){_0xf0f683=_0xf0f683-0x0;var _0x465dee=_0x88fc[_0xf0f683];return _0x465dee;};'use strict';var _=require(_0xc88f('0x0'));var util=require(_0xc88f('0x1'));var moment=require(_0xc88f('0x2'));var BPromise=require(_0xc88f('0x3'));var rs=require(_0xc88f('0x4'));var fs=require('fs');var Redis=require(_0xc88f('0x5'));var db=require(_0xc88f('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xc88f('0x7'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xc88f('0x8')][_0xc88f('0x9')]({'port':0x232a});config[_0xc88f('0xa')]=_['defaults'](config[_0xc88f('0xa')],{'host':_0xc88f('0xb'),'port':0x18eb});var socket=require(_0xc88f('0xc'))(new Redis(config['redis']));require(_0xc88f('0xd'))[_0xc88f('0xe')](socket);function respondWithRpcPromise(_0x56bd3d,_0x241ee5,_0x37d29){return new BPromise(function(_0x1774c2,_0xa11650){return client['request'](_0x56bd3d,_0x37d29)[_0xc88f('0xf')](function(_0x112831){logger[_0xc88f('0x10')](_0xc88f('0x11'),_0x241ee5,_0xc88f('0x12'));logger[_0xc88f('0x13')]('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x241ee5,_0xc88f('0x12'),JSON[_0xc88f('0x14')](_0x112831));if(_0x112831[_0xc88f('0x15')]){if(_0x112831[_0xc88f('0x15')]['code']===0x1f4){logger[_0xc88f('0x15')](_0xc88f('0x11'),_0x241ee5,_0x112831['error']['message']);return _0xa11650(_0x112831[_0xc88f('0x15')][_0xc88f('0x16')]);}logger['error'](_0xc88f('0x11'),_0x241ee5,_0x112831[_0xc88f('0x15')][_0xc88f('0x16')]);return _0x1774c2(_0x112831[_0xc88f('0x15')]['message']);}else{logger[_0xc88f('0x10')](_0xc88f('0x11'),_0x241ee5,_0xc88f('0x12'));_0x1774c2(_0x112831[_0xc88f('0x17')][_0xc88f('0x16')]);}})[_0xc88f('0x18')](function(_0x29a67f){logger[_0xc88f('0x15')](_0xc88f('0x11'),_0x241ee5,_0x29a67f);_0xa11650(_0x29a67f);});});}exports[_0xc88f('0x19')]=function(_0x290926){var _0x570304=this;return new Promise(function(_0x11308b,_0x7525d1){return db[_0xc88f('0x1a')]['findAll']({'raw':_0x290926[_0xc88f('0x1b')]?_0x290926['options'][_0xc88f('0x1c')]===undefined?!![]:![]:!![],'where':_0x290926[_0xc88f('0x1b')]?_0x290926[_0xc88f('0x1b')][_0xc88f('0x1d')]||null:null,'attributes':[[db[_0xc88f('0x1e')]['fn'](_0xc88f('0x1f'),db[_0xc88f('0x1e')]['fn']('IF',db[_0xc88f('0x1e')]['literal'](_0xc88f('0x20')))),_0xc88f('0x21')]]})[_0xc88f('0xf')](function(_0x34d533){logger[_0xc88f('0x10')](_0xc88f('0x19'),_0x290926);logger[_0xc88f('0x13')]('GetVoiceQueueRtPauses',_0x290926,JSON[_0xc88f('0x14')](_0x34d533));_0x11308b(_0x34d533);})[_0xc88f('0x18')](function(_0x3aa47b){logger[_0xc88f('0x15')](_0xc88f('0x19'),_0x3aa47b[_0xc88f('0x16')],_0x290926);_0x7525d1(_0x570304[_0xc88f('0x15')](0x1f4,_0x3aa47b['message']));});});};