f16fce84e8f260235282d9080ecc711e170dae47
[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 _0xde1a=['../../config/environment','client','redis','defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','then','info','request\x20sent','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','UserVoiceQueueRt,\x20%s,\x20%s','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','options','where','sequelize','literal','debug','util','bluebird','randomstring','ioredis','rpc'];(function(_0x588f0f,_0x26d4ec){var _0x379384=function(_0x1a144e){while(--_0x1a144e){_0x588f0f['push'](_0x588f0f['shift']());}};_0x379384(++_0x26d4ec);}(_0xde1a,0x16f));var _0xade1=function(_0x4a9f6f,_0x517f3f){_0x4a9f6f=_0x4a9f6f-0x0;var _0x3b3ceb=_0xde1a[_0x4a9f6f];return _0x3b3ceb;};'use strict';var _=require('lodash');var util=require(_0xade1('0x0'));var moment=require('moment');var BPromise=require(_0xade1('0x1'));var rs=require(_0xade1('0x2'));var fs=require('fs');var Redis=require(_0xade1('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xade1('0x4'));var config=require(_0xade1('0x5'));var jayson=require('jayson/promise');var client=jayson[_0xade1('0x6')]['http']({'port':0x232a});config[_0xade1('0x7')]=_[_0xade1('0x8')](config[_0xade1('0x7')],{'host':_0xade1('0x9'),'port':0x18eb});var socket=require(_0xade1('0xa'))(new Redis(config['redis']));require(_0xade1('0xb'))[_0xade1('0xc')](socket);function respondWithRpcPromise(_0x1101ed,_0x4f3274,_0x10cced){return new BPromise(function(_0x4e5516,_0x48e7db){return client['request'](_0x1101ed,_0x10cced)[_0xade1('0xd')](function(_0x2287b5){logger[_0xade1('0xe')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x4f3274,_0xade1('0xf'));logger['debug'](_0xade1('0x10'),_0x4f3274,_0xade1('0xf'),JSON[_0xade1('0x11')](_0x2287b5));if(_0x2287b5[_0xade1('0x12')]){if(_0x2287b5[_0xade1('0x12')][_0xade1('0x13')]===0x1f4){logger[_0xade1('0x12')](_0xade1('0x14'),_0x4f3274,_0x2287b5[_0xade1('0x12')][_0xade1('0x15')]);return _0x48e7db(_0x2287b5[_0xade1('0x12')][_0xade1('0x15')]);}logger[_0xade1('0x12')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x4f3274,_0x2287b5[_0xade1('0x12')][_0xade1('0x15')]);return _0x4e5516(_0x2287b5[_0xade1('0x12')]['message']);}else{logger[_0xade1('0xe')](_0xade1('0x14'),_0x4f3274,_0xade1('0xf'));_0x4e5516(_0x2287b5[_0xade1('0x16')]['message']);}})[_0xade1('0x17')](function(_0x503deb){logger[_0xade1('0x12')](_0xade1('0x14'),_0x4f3274,_0x503deb);_0x48e7db(_0x503deb);});});}exports[_0xade1('0x18')]=function(_0x45f4c5){var _0x5da2b5=this;return new Promise(function(_0x89f894,_0x44b50a){return db[_0xade1('0x19')]['findAll']({'raw':_0x45f4c5['options']?_0x45f4c5[_0xade1('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x45f4c5[_0xade1('0x1a')]?_0x45f4c5[_0xade1('0x1a')][_0xade1('0x1b')]||null:null,'attributes':[[db['sequelize']['fn']('COUNT',db[_0xade1('0x1c')]['fn']('IF',db['sequelize'][_0xade1('0x1d')]('`paused`\x20=\x201,\x201,\x20null'))),'outboundQueuePauses']]})[_0xade1('0xd')](function(_0x2c9639){logger[_0xade1('0xe')](_0xade1('0x18'),_0x45f4c5);logger[_0xade1('0x1e')]('GetVoiceQueueRtPauses',_0x45f4c5,JSON['stringify'](_0x2c9639));_0x89f894(_0x2c9639);})['catch'](function(_0x50569e){logger[_0xade1('0x12')](_0xade1('0x18'),_0x50569e[_0xade1('0x15')],_0x45f4c5);_0x44b50a(_0x5da2b5['error'](0x1f4,_0x50569e[_0xade1('0x15')]));});});};