Built motion from commit a61a4a20.|2.5.46
[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 _0x712e=['message','result','catch','UserVoiceQueueRt','findAll','options','raw','where','sequelize','COUNT','literal','GetVoiceQueueRtPauses','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','jayson/promise','http','redis','defaults','localhost','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code'];(function(_0x264512,_0x1f4434){var _0xd80d63=function(_0x164544){while(--_0x164544){_0x264512['push'](_0x264512['shift']());}};_0xd80d63(++_0x1f4434);}(_0x712e,0x198));var _0xe712=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x712e[_0x321bb2];return _0x9c12ed;};'use strict';var _=require(_0xe712('0x0'));var util=require('util');var moment=require(_0xe712('0x1'));var BPromise=require(_0xe712('0x2'));var rs=require(_0xe712('0x3'));var fs=require('fs');var Redis=require(_0xe712('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xe712('0x5'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0xe712('0x6'));var client=jayson['client'][_0xe712('0x7')]({'port':0x232a});config[_0xe712('0x8')]=_[_0xe712('0x9')](config[_0xe712('0x8')],{'host':_0xe712('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./userVoiceQueueRt.socket')[_0xe712('0xb')](socket);function respondWithRpcPromise(_0x359707,_0x11898e,_0x4d3675){return new BPromise(function(_0x1f96da,_0x2de972){return client[_0xe712('0xc')](_0x359707,_0x4d3675)[_0xe712('0xd')](function(_0x591dc7){logger[_0xe712('0xe')](_0xe712('0xf'),_0x11898e,_0xe712('0x10'));logger[_0xe712('0x11')]('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x11898e,_0xe712('0x10'),JSON[_0xe712('0x12')](_0x591dc7));if(_0x591dc7[_0xe712('0x13')]){if(_0x591dc7[_0xe712('0x13')][_0xe712('0x14')]===0x1f4){logger['error'](_0xe712('0xf'),_0x11898e,_0x591dc7[_0xe712('0x13')][_0xe712('0x15')]);return _0x2de972(_0x591dc7['error']['message']);}logger[_0xe712('0x13')](_0xe712('0xf'),_0x11898e,_0x591dc7['error'][_0xe712('0x15')]);return _0x1f96da(_0x591dc7[_0xe712('0x13')][_0xe712('0x15')]);}else{logger[_0xe712('0xe')](_0xe712('0xf'),_0x11898e,_0xe712('0x10'));_0x1f96da(_0x591dc7[_0xe712('0x16')][_0xe712('0x15')]);}})[_0xe712('0x17')](function(_0x4651a2){logger[_0xe712('0x13')](_0xe712('0xf'),_0x11898e,_0x4651a2);_0x2de972(_0x4651a2);});});}exports['GetVoiceQueueRtPauses']=function(_0x4bbe87){var _0x3b54b9=this;return new Promise(function(_0x398ee5,_0x7dde3c){return db[_0xe712('0x18')][_0xe712('0x19')]({'raw':_0x4bbe87[_0xe712('0x1a')]?_0x4bbe87[_0xe712('0x1a')][_0xe712('0x1b')]===undefined?!![]:![]:!![],'where':_0x4bbe87['options']?_0x4bbe87[_0xe712('0x1a')][_0xe712('0x1c')]||null:null,'attributes':[[db[_0xe712('0x1d')]['fn'](_0xe712('0x1e'),db[_0xe712('0x1d')]['fn']('IF',db[_0xe712('0x1d')][_0xe712('0x1f')]('`paused`\x20=\x201,\x201,\x20null'))),'outboundQueuePauses']]})['then'](function(_0x4d8982){logger['info'](_0xe712('0x20'),_0x4bbe87);logger[_0xe712('0x11')](_0xe712('0x20'),_0x4bbe87,JSON['stringify'](_0x4d8982));_0x398ee5(_0x4d8982);})['catch'](function(_0x4c606c){logger['error']('GetVoiceQueueRtPauses',_0x4c606c['message'],_0x4bbe87);_0x7dde3c(_0x3b54b9['error'](0x1f4,_0x4c606c[_0xe712('0x15')]));});});};