Built motion from commit 9d0783e6.|2.6.13
[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 _0x4adc=['code','message','result','catch','UserVoiceQueueRt','findAll','options','raw','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','GetVoiceQueueRtPauses','debug','lodash','bluebird','../../config/logger','rpc','jayson/promise','client','redis','localhost','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error'];(function(_0x430f44,_0x4ae21b){var _0x1f6b0f=function(_0x35968f){while(--_0x35968f){_0x430f44['push'](_0x430f44['shift']());}};_0x1f6b0f(++_0x4ae21b);}(_0x4adc,0x150));var _0xc4ad=function(_0x5f1391,_0x19c132){_0x5f1391=_0x5f1391-0x0;var _0x50ebe3=_0x4adc[_0x5f1391];return _0x50ebe3;};'use strict';var _=require(_0xc4ad('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xc4ad('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xc4ad('0x2'))(_0xc4ad('0x3'));var config=require('../../config/environment');var jayson=require(_0xc4ad('0x4'));var client=jayson[_0xc4ad('0x5')]['http']({'port':0x232a});config[_0xc4ad('0x6')]=_['defaults'](config[_0xc4ad('0x6')],{'host':_0xc4ad('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc4ad('0x6')]));require('./userVoiceQueueRt.socket')['register'](socket);function respondWithRpcPromise(_0x243db9,_0x15664d,_0x67f301){return new BPromise(function(_0x39b59f,_0x3720aa){return client[_0xc4ad('0x8')](_0x243db9,_0x67f301)[_0xc4ad('0x9')](function(_0x1b9e33){logger[_0xc4ad('0xa')](_0xc4ad('0xb'),_0x15664d,'request\x20sent');logger['debug'](_0xc4ad('0xc'),_0x15664d,_0xc4ad('0xd'),JSON[_0xc4ad('0xe')](_0x1b9e33));if(_0x1b9e33[_0xc4ad('0xf')]){if(_0x1b9e33['error'][_0xc4ad('0x10')]===0x1f4){logger[_0xc4ad('0xf')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x15664d,_0x1b9e33[_0xc4ad('0xf')][_0xc4ad('0x11')]);return _0x3720aa(_0x1b9e33[_0xc4ad('0xf')][_0xc4ad('0x11')]);}logger[_0xc4ad('0xf')](_0xc4ad('0xb'),_0x15664d,_0x1b9e33['error']['message']);return _0x39b59f(_0x1b9e33[_0xc4ad('0xf')][_0xc4ad('0x11')]);}else{logger['info'](_0xc4ad('0xb'),_0x15664d,'request\x20sent');_0x39b59f(_0x1b9e33[_0xc4ad('0x12')]['message']);}})[_0xc4ad('0x13')](function(_0x4fc14c){logger[_0xc4ad('0xf')](_0xc4ad('0xb'),_0x15664d,_0x4fc14c);_0x3720aa(_0x4fc14c);});});}exports['GetVoiceQueueRtPauses']=function(_0x4a848c){var _0x40f010=this;return new Promise(function(_0x16b6c8,_0x5335bf){return db[_0xc4ad('0x14')][_0xc4ad('0x15')]({'raw':_0x4a848c[_0xc4ad('0x16')]?_0x4a848c[_0xc4ad('0x16')][_0xc4ad('0x17')]===undefined?!![]:![]:!![],'where':_0x4a848c[_0xc4ad('0x16')]?_0x4a848c[_0xc4ad('0x16')][_0xc4ad('0x18')]||null:null,'attributes':[[db[_0xc4ad('0x19')]['fn'](_0xc4ad('0x1a'),db[_0xc4ad('0x19')]['fn']('IF',db[_0xc4ad('0x19')][_0xc4ad('0x1b')](_0xc4ad('0x1c')))),_0xc4ad('0x1d')]]})['then'](function(_0x38bdc1){logger[_0xc4ad('0xa')](_0xc4ad('0x1e'),_0x4a848c);logger[_0xc4ad('0x1f')](_0xc4ad('0x1e'),_0x4a848c,JSON['stringify'](_0x38bdc1));_0x16b6c8(_0x38bdc1);})[_0xc4ad('0x13')](function(_0x2ed0d8){logger[_0xc4ad('0xf')](_0xc4ad('0x1e'),_0x2ed0d8['message'],_0x4a848c);_0x5335bf(_0x40f010[_0xc4ad('0xf')](0x1f4,_0x2ed0d8[_0xc4ad('0x11')]));});});};