Built motion from commit (unavailable).|2.5.31
[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 _0x66bc=['jayson/promise','client','http','redis','localhost','socket.io-emitter','register','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','code','error','message','catch','UserVoiceQueueRt','findAll','options','raw','where','sequelize','COUNT','literal','outboundQueuePauses','then','GetVoiceQueueRtPauses','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment'];(function(_0x2c3299,_0x28de8e){var _0x1becd1=function(_0x2d65a8){while(--_0x2d65a8){_0x2c3299['push'](_0x2c3299['shift']());}};_0x1becd1(++_0x28de8e);}(_0x66bc,0x169));var _0xc66b=function(_0x3cde63,_0x53d16d){_0x3cde63=_0x3cde63-0x0;var _0x216599=_0x66bc[_0x3cde63];return _0x216599;};'use strict';var _=require(_0xc66b('0x0'));var util=require(_0xc66b('0x1'));var moment=require(_0xc66b('0x2'));var BPromise=require(_0xc66b('0x3'));var rs=require(_0xc66b('0x4'));var fs=require('fs');var Redis=require(_0xc66b('0x5'));var db=require(_0xc66b('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xc66b('0x7'))('rpc');var config=require(_0xc66b('0x8'));var jayson=require(_0xc66b('0x9'));var client=jayson[_0xc66b('0xa')][_0xc66b('0xb')]({'port':0x232a});config[_0xc66b('0xc')]=_['defaults'](config['redis'],{'host':_0xc66b('0xd'),'port':0x18eb});var socket=require(_0xc66b('0xe'))(new Redis(config[_0xc66b('0xc')]));require('./userVoiceQueueRt.socket')[_0xc66b('0xf')](socket);function respondWithRpcPromise(_0x1c7b3c,_0x584acf,_0x5785c2){return new BPromise(function(_0x463ab9,_0x2fb5ec){return client['request'](_0x1c7b3c,_0x5785c2)['then'](function(_0x2cc6df){logger[_0xc66b('0x10')](_0xc66b('0x11'),_0x584acf,_0xc66b('0x12'));logger[_0xc66b('0x13')](_0xc66b('0x14'),_0x584acf,_0xc66b('0x12'),JSON['stringify'](_0x2cc6df));if(_0x2cc6df['error']){if(_0x2cc6df['error'][_0xc66b('0x15')]===0x1f4){logger[_0xc66b('0x16')](_0xc66b('0x11'),_0x584acf,_0x2cc6df[_0xc66b('0x16')]['message']);return _0x2fb5ec(_0x2cc6df[_0xc66b('0x16')][_0xc66b('0x17')]);}logger[_0xc66b('0x16')](_0xc66b('0x11'),_0x584acf,_0x2cc6df[_0xc66b('0x16')]['message']);return _0x463ab9(_0x2cc6df[_0xc66b('0x16')][_0xc66b('0x17')]);}else{logger[_0xc66b('0x10')](_0xc66b('0x11'),_0x584acf,_0xc66b('0x12'));_0x463ab9(_0x2cc6df['result'][_0xc66b('0x17')]);}})[_0xc66b('0x18')](function(_0x1a29c4){logger['error'](_0xc66b('0x11'),_0x584acf,_0x1a29c4);_0x2fb5ec(_0x1a29c4);});});}exports['GetVoiceQueueRtPauses']=function(_0x1155ee){var _0x5d0c16=this;return new Promise(function(_0x12ad61,_0x2d3ed3){return db[_0xc66b('0x19')][_0xc66b('0x1a')]({'raw':_0x1155ee[_0xc66b('0x1b')]?_0x1155ee[_0xc66b('0x1b')][_0xc66b('0x1c')]===undefined?!![]:![]:!![],'where':_0x1155ee[_0xc66b('0x1b')]?_0x1155ee[_0xc66b('0x1b')][_0xc66b('0x1d')]||null:null,'attributes':[[db[_0xc66b('0x1e')]['fn'](_0xc66b('0x1f'),db[_0xc66b('0x1e')]['fn']('IF',db[_0xc66b('0x1e')][_0xc66b('0x20')]('`paused`\x20=\x201,\x201,\x20null'))),_0xc66b('0x21')]]})[_0xc66b('0x22')](function(_0x279d5c){logger['info'](_0xc66b('0x23'),_0x1155ee);logger[_0xc66b('0x13')](_0xc66b('0x23'),_0x1155ee,JSON[_0xc66b('0x24')](_0x279d5c));_0x12ad61(_0x279d5c);})[_0xc66b('0x18')](function(_0x15fbc1){logger['error'](_0xc66b('0x23'),_0x15fbc1['message'],_0x1155ee);_0x2d3ed3(_0x5d0c16['error'](0x1f4,_0x15fbc1['message']));});});};