01e87afcc5cbccfc67a042536a60c86dade37996
[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 _0xc15a=['defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','UserVoiceQueueRt','options','raw','where','COUNT','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','GetVoiceQueueRtPauses','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','jayson/promise','redis'];(function(_0x1b9542,_0x2b4591){var _0x8996da=function(_0x556238){while(--_0x556238){_0x1b9542['push'](_0x1b9542['shift']());}};_0x8996da(++_0x2b4591);}(_0xc15a,0x1d4));var _0xac15=function(_0x251635,_0x5c50d6){_0x251635=_0x251635-0x0;var _0x2ec38a=_0xc15a[_0x251635];return _0x2ec38a;};'use strict';var _=require(_0xac15('0x0'));var util=require(_0xac15('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xac15('0x2'));var fs=require('fs');var Redis=require(_0xac15('0x3'));var db=require(_0xac15('0x4'))['db'];var utils=require(_0xac15('0x5'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0xac15('0x6'));var client=jayson['client']['http']({'port':0x232a});config[_0xac15('0x7')]=_[_0xac15('0x8')](config[_0xac15('0x7')],{'host':_0xac15('0x9'),'port':0x18eb});var socket=require(_0xac15('0xa'))(new Redis(config[_0xac15('0x7')]));require(_0xac15('0xb'))['register'](socket);function respondWithRpcPromise(_0x2a44c3,_0x47d223,_0x57ca38){return new BPromise(function(_0x269b00,_0xddb651){return client[_0xac15('0xc')](_0x2a44c3,_0x57ca38)[_0xac15('0xd')](function(_0x225d1b){logger[_0xac15('0xe')](_0xac15('0xf'),_0x47d223,_0xac15('0x10'));logger[_0xac15('0x11')](_0xac15('0x12'),_0x47d223,_0xac15('0x10'),JSON[_0xac15('0x13')](_0x225d1b));if(_0x225d1b['error']){if(_0x225d1b['error']['code']===0x1f4){logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x47d223,_0x225d1b['error']['message']);return _0xddb651(_0x225d1b[_0xac15('0x14')][_0xac15('0x15')]);}logger[_0xac15('0x14')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x47d223,_0x225d1b[_0xac15('0x14')][_0xac15('0x15')]);return _0x269b00(_0x225d1b[_0xac15('0x14')][_0xac15('0x15')]);}else{logger[_0xac15('0xe')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x47d223,_0xac15('0x10'));_0x269b00(_0x225d1b[_0xac15('0x16')][_0xac15('0x15')]);}})[_0xac15('0x17')](function(_0x2fbd87){logger[_0xac15('0x14')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x47d223,_0x2fbd87);_0xddb651(_0x2fbd87);});});}exports['GetVoiceQueueRtPauses']=function(_0x3f9d80){var _0x176907=this;return new Promise(function(_0x35261e,_0x59ce90){return db[_0xac15('0x18')]['findAll']({'raw':_0x3f9d80[_0xac15('0x19')]?_0x3f9d80['options'][_0xac15('0x1a')]===undefined?!![]:![]:!![],'where':_0x3f9d80[_0xac15('0x19')]?_0x3f9d80[_0xac15('0x19')][_0xac15('0x1b')]||null:null,'attributes':[[db['sequelize']['fn'](_0xac15('0x1c'),db[_0xac15('0x1d')]['fn']('IF',db[_0xac15('0x1d')][_0xac15('0x1e')](_0xac15('0x1f')))),_0xac15('0x20')]]})[_0xac15('0xd')](function(_0x3f1aa8){logger['info'](_0xac15('0x21'),_0x3f9d80);logger[_0xac15('0x11')](_0xac15('0x21'),_0x3f9d80,JSON[_0xac15('0x13')](_0x3f1aa8));_0x35261e(_0x3f1aa8);})[_0xac15('0x17')](function(_0xb28dd5){logger[_0xac15('0x14')]('GetVoiceQueueRtPauses',_0xb28dd5[_0xac15('0x15')],_0x3f9d80);_0x59ce90(_0x176907[_0xac15('0x14')](0x1f4,_0xb28dd5[_0xac15('0x15')]));});});};