0d127975764377c59a11797fbdd17abd729ef2f8
[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 _0x62f9=['then','catch','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','http','redis','defaults','localhost','./userVoiceQueueRt.socket','register','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','error','code','message','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','where','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses'];(function(_0x908173,_0x10430c){var _0x16c1d3=function(_0x45029d){while(--_0x45029d){_0x908173['push'](_0x908173['shift']());}};_0x16c1d3(++_0x10430c);}(_0x62f9,0x1f2));var _0x962f=function(_0xf168d3,_0x43dcfc){_0xf168d3=_0xf168d3-0x0;var _0x17fb54=_0x62f9[_0xf168d3];return _0x17fb54;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x962f('0x0'));var rs=require(_0x962f('0x1'));var fs=require('fs');var Redis=require(_0x962f('0x2'));var db=require(_0x962f('0x3'))['db'];var utils=require(_0x962f('0x4'));var logger=require('../../config/logger')(_0x962f('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x962f('0x6')]({'port':0x232a});config[_0x962f('0x7')]=_[_0x962f('0x8')](config['redis'],{'host':_0x962f('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x962f('0x7')]));require(_0x962f('0xa'))[_0x962f('0xb')](socket);function respondWithRpcPromise(_0x3c4d0a,_0x40daa0,_0x4c26c8){return new BPromise(function(_0x398590,_0x5998bc){return client['request'](_0x3c4d0a,_0x4c26c8)['then'](function(_0x4f0235){logger[_0x962f('0xc')](_0x962f('0xd'),_0x40daa0,_0x962f('0xe'));logger['debug'](_0x962f('0xf'),_0x40daa0,'request\x20sent',JSON['stringify'](_0x4f0235));if(_0x4f0235[_0x962f('0x10')]){if(_0x4f0235[_0x962f('0x10')][_0x962f('0x11')]===0x1f4){logger['error'](_0x962f('0xd'),_0x40daa0,_0x4f0235[_0x962f('0x10')][_0x962f('0x12')]);return _0x5998bc(_0x4f0235[_0x962f('0x10')][_0x962f('0x12')]);}logger[_0x962f('0x10')](_0x962f('0xd'),_0x40daa0,_0x4f0235[_0x962f('0x10')][_0x962f('0x12')]);return _0x398590(_0x4f0235[_0x962f('0x10')][_0x962f('0x12')]);}else{logger[_0x962f('0xc')](_0x962f('0xd'),_0x40daa0,_0x962f('0xe'));_0x398590(_0x4f0235['result'][_0x962f('0x12')]);}})['catch'](function(_0x507062){logger[_0x962f('0x10')](_0x962f('0xd'),_0x40daa0,_0x507062);_0x5998bc(_0x507062);});});}exports[_0x962f('0x13')]=function(_0x1f11b3){var _0x1d5089=this;return new Promise(function(_0x336fc5,_0x2e5407){return db[_0x962f('0x14')][_0x962f('0x15')]({'raw':_0x1f11b3[_0x962f('0x16')]?_0x1f11b3[_0x962f('0x16')][_0x962f('0x17')]===undefined?!![]:![]:!![],'where':_0x1f11b3[_0x962f('0x16')]?_0x1f11b3['options'][_0x962f('0x18')]||null:null,'attributes':[[db[_0x962f('0x19')]['fn']('COUNT',db[_0x962f('0x19')]['fn']('IF',db[_0x962f('0x19')][_0x962f('0x1a')](_0x962f('0x1b')))),_0x962f('0x1c')]]})[_0x962f('0x1d')](function(_0x4943cb){logger[_0x962f('0xc')](_0x962f('0x13'),_0x1f11b3);logger['debug'](_0x962f('0x13'),_0x1f11b3,JSON['stringify'](_0x4943cb));_0x336fc5(_0x4943cb);})[_0x962f('0x1e')](function(_0x5078fc){logger[_0x962f('0x10')]('GetVoiceQueueRtPauses',_0x5078fc[_0x962f('0x12')],_0x1f11b3);_0x2e5407(_0x1d5089[_0x962f('0x10')](0x1f4,_0x5078fc[_0x962f('0x12')]));});});};