77f141e9fbbd4d2f722db674e5e84e1e482a617d
[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 _0x1575=['`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','util','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register','then','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','code','message','error','info','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','sequelize','literal'];(function(_0x47cedd,_0x35f120){var _0x2fd2ce=function(_0x28cffb){while(--_0x28cffb){_0x47cedd['push'](_0x47cedd['shift']());}};_0x2fd2ce(++_0x35f120);}(_0x1575,0x183));var _0x5157=function(_0x5b7e2e,_0x689e00){_0x5b7e2e=_0x5b7e2e-0x0;var _0x31c1a2=_0x1575[_0x5b7e2e];return _0x31c1a2;};'use strict';var _=require('lodash');var util=require(_0x5157('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5157('0x1'));var db=require('../../mysqldb')['db'];var utils=require(_0x5157('0x2'));var logger=require(_0x5157('0x3'))(_0x5157('0x4'));var config=require(_0x5157('0x5'));var jayson=require(_0x5157('0x6'));var client=jayson[_0x5157('0x7')][_0x5157('0x8')]({'port':0x232a});config['redis']=_[_0x5157('0x9')](config[_0x5157('0xa')],{'host':_0x5157('0xb'),'port':0x18eb});var socket=require(_0x5157('0xc'))(new Redis(config[_0x5157('0xa')]));require('./userVoiceQueueRt.socket')[_0x5157('0xd')](socket);function respondWithRpcPromise(_0x337f1b,_0x5e0687,_0x11b481){return new BPromise(function(_0x525cf4,_0x2c3047){return client['request'](_0x337f1b,_0x11b481)[_0x5157('0xe')](function(_0x2b872d){logger['info'](_0x5157('0xf'),_0x5e0687,_0x5157('0x10'));logger[_0x5157('0x11')](_0x5157('0x12'),_0x5e0687,'request\x20sent',JSON[_0x5157('0x13')](_0x2b872d));if(_0x2b872d['error']){if(_0x2b872d['error'][_0x5157('0x14')]===0x1f4){logger['error'](_0x5157('0xf'),_0x5e0687,_0x2b872d['error'][_0x5157('0x15')]);return _0x2c3047(_0x2b872d[_0x5157('0x16')][_0x5157('0x15')]);}logger['error'](_0x5157('0xf'),_0x5e0687,_0x2b872d[_0x5157('0x16')][_0x5157('0x15')]);return _0x525cf4(_0x2b872d[_0x5157('0x16')][_0x5157('0x15')]);}else{logger[_0x5157('0x17')](_0x5157('0xf'),_0x5e0687,'request\x20sent');_0x525cf4(_0x2b872d[_0x5157('0x18')][_0x5157('0x15')]);}})[_0x5157('0x19')](function(_0x1ba228){logger[_0x5157('0x16')](_0x5157('0xf'),_0x5e0687,_0x1ba228);_0x2c3047(_0x1ba228);});});}exports[_0x5157('0x1a')]=function(_0x45675c){var _0x114fc2=this;return new Promise(function(_0x40889e,_0x1db644){return db[_0x5157('0x1b')][_0x5157('0x1c')]({'raw':_0x45675c[_0x5157('0x1d')]?_0x45675c['options'][_0x5157('0x1e')]===undefined?!![]:![]:!![],'where':_0x45675c[_0x5157('0x1d')]?_0x45675c['options']['where']||null:null,'attributes':[[db[_0x5157('0x1f')]['fn']('COUNT',db[_0x5157('0x1f')]['fn']('IF',db[_0x5157('0x1f')][_0x5157('0x20')](_0x5157('0x21')))),_0x5157('0x22')]]})['then'](function(_0x3db5bc){logger[_0x5157('0x17')](_0x5157('0x1a'),_0x45675c);logger['debug'](_0x5157('0x1a'),_0x45675c,JSON[_0x5157('0x13')](_0x3db5bc));_0x40889e(_0x3db5bc);})['catch'](function(_0x76f13a){logger[_0x5157('0x16')](_0x5157('0x1a'),_0x76f13a[_0x5157('0x15')],_0x45675c);_0x1db644(_0x114fc2[_0x5157('0x16')](0x1f4,_0x76f13a[_0x5157('0x15')]));});});};