Built motion from commit (unavailable).|2.5.28
[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 _0x23a1=['result','GetVoiceQueueRtPauses','findAll','options','where','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','catch','lodash','bluebird','randomstring','../../config/utils','../../config/logger','rpc','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message'];(function(_0x565569,_0x5c0375){var _0x1ac5da=function(_0x1f052b){while(--_0x1f052b){_0x565569['push'](_0x565569['shift']());}};_0x1ac5da(++_0x5c0375);}(_0x23a1,0x1ea));var _0x123a=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x23a1[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0x123a('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x123a('0x1'));var rs=require(_0x123a('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x123a('0x3'));var logger=require(_0x123a('0x4'))(_0x123a('0x5'));var config=require('../../config/environment');var jayson=require(_0x123a('0x6'));var client=jayson['client'][_0x123a('0x7')]({'port':0x232a});config[_0x123a('0x8')]=_[_0x123a('0x9')](config[_0x123a('0x8')],{'host':_0x123a('0xa'),'port':0x18eb});var socket=require(_0x123a('0xb'))(new Redis(config[_0x123a('0x8')]));require(_0x123a('0xc'))[_0x123a('0xd')](socket);function respondWithRpcPromise(_0x5a4ce9,_0x3a29cf,_0x3764a4){return new BPromise(function(_0x440262,_0x58d3dc){return client['request'](_0x5a4ce9,_0x3764a4)[_0x123a('0xe')](function(_0x2d49e4){logger[_0x123a('0xf')](_0x123a('0x10'),_0x3a29cf,_0x123a('0x11'));logger[_0x123a('0x12')]('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x3a29cf,'request\x20sent',JSON[_0x123a('0x13')](_0x2d49e4));if(_0x2d49e4[_0x123a('0x14')]){if(_0x2d49e4[_0x123a('0x14')]['code']===0x1f4){logger[_0x123a('0x14')](_0x123a('0x10'),_0x3a29cf,_0x2d49e4['error']['message']);return _0x58d3dc(_0x2d49e4[_0x123a('0x14')][_0x123a('0x15')]);}logger['error'](_0x123a('0x10'),_0x3a29cf,_0x2d49e4[_0x123a('0x14')]['message']);return _0x440262(_0x2d49e4['error'][_0x123a('0x15')]);}else{logger['info'](_0x123a('0x10'),_0x3a29cf,_0x123a('0x11'));_0x440262(_0x2d49e4[_0x123a('0x16')]['message']);}})['catch'](function(_0x4df930){logger[_0x123a('0x14')](_0x123a('0x10'),_0x3a29cf,_0x4df930);_0x58d3dc(_0x4df930);});});}exports[_0x123a('0x17')]=function(_0x1fe161){var _0x1ea6c4=this;return new Promise(function(_0x1d9ff2,_0x1968a9){return db['UserVoiceQueueRt'][_0x123a('0x18')]({'raw':_0x1fe161[_0x123a('0x19')]?_0x1fe161['options']['raw']===undefined?!![]:![]:!![],'where':_0x1fe161[_0x123a('0x19')]?_0x1fe161[_0x123a('0x19')][_0x123a('0x1a')]||null:null,'attributes':[[db['sequelize']['fn']('COUNT',db[_0x123a('0x1b')]['fn']('IF',db[_0x123a('0x1b')][_0x123a('0x1c')](_0x123a('0x1d')))),_0x123a('0x1e')]]})[_0x123a('0xe')](function(_0x15dd94){logger[_0x123a('0xf')]('GetVoiceQueueRtPauses',_0x1fe161);logger['debug'](_0x123a('0x17'),_0x1fe161,JSON[_0x123a('0x13')](_0x15dd94));_0x1d9ff2(_0x15dd94);})[_0x123a('0x1f')](function(_0x3a124c){logger[_0x123a('0x14')](_0x123a('0x17'),_0x3a124c[_0x123a('0x15')],_0x1fe161);_0x1968a9(_0x1ea6c4[_0x123a('0x14')](0x1f4,_0x3a124c[_0x123a('0x15')]));});});};