fe3d63307b73f5d7dbd60b99cf8c438a23b6ee9a
[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 _0x9a78=['bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','redis','defaults','socket.io-emitter','register','then','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','options','raw','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','info','stringify','lodash','util','moment'];(function(_0x5dbfb7,_0x482a03){var _0x359cc4=function(_0x32696b){while(--_0x32696b){_0x5dbfb7['push'](_0x5dbfb7['shift']());}};_0x359cc4(++_0x482a03);}(_0x9a78,0xb6));var _0x89a7=function(_0xe4aadc,_0x31f7a5){_0xe4aadc=_0xe4aadc-0x0;var _0x583a98=_0x9a78[_0xe4aadc];return _0x583a98;};'use strict';var _=require(_0x89a7('0x0'));var util=require(_0x89a7('0x1'));var moment=require(_0x89a7('0x2'));var BPromise=require(_0x89a7('0x3'));var rs=require(_0x89a7('0x4'));var fs=require('fs');var Redis=require(_0x89a7('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x89a7('0x6'));var logger=require(_0x89a7('0x7'))('rpc');var config=require(_0x89a7('0x8'));var jayson=require(_0x89a7('0x9'));var client=jayson['client'][_0x89a7('0xa')]({'port':0x232a});config[_0x89a7('0xb')]=_[_0x89a7('0xc')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x89a7('0xd'))(new Redis(config['redis']));require('./userVoiceQueueRt.socket')[_0x89a7('0xe')](socket);function respondWithRpcPromise(_0x3415e6,_0xf6c3ac,_0x4223d9){return new BPromise(function(_0x3cb764,_0x3f5fed){return client['request'](_0x3415e6,_0x4223d9)[_0x89a7('0xf')](function(_0x3587b3){logger['info'](_0x89a7('0x10'),_0xf6c3ac,_0x89a7('0x11'));logger[_0x89a7('0x12')](_0x89a7('0x13'),_0xf6c3ac,'request\x20sent',JSON['stringify'](_0x3587b3));if(_0x3587b3['error']){if(_0x3587b3[_0x89a7('0x14')][_0x89a7('0x15')]===0x1f4){logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0xf6c3ac,_0x3587b3[_0x89a7('0x14')][_0x89a7('0x16')]);return _0x3f5fed(_0x3587b3[_0x89a7('0x14')]['message']);}logger['error'](_0x89a7('0x10'),_0xf6c3ac,_0x3587b3[_0x89a7('0x14')][_0x89a7('0x16')]);return _0x3cb764(_0x3587b3[_0x89a7('0x14')][_0x89a7('0x16')]);}else{logger['info'](_0x89a7('0x10'),_0xf6c3ac,_0x89a7('0x11'));_0x3cb764(_0x3587b3[_0x89a7('0x17')]['message']);}})[_0x89a7('0x18')](function(_0x45c508){logger[_0x89a7('0x14')](_0x89a7('0x10'),_0xf6c3ac,_0x45c508);_0x3f5fed(_0x45c508);});});}exports[_0x89a7('0x19')]=function(_0x2c5ab4){var _0x1ab449=this;return new Promise(function(_0xece1dd,_0x128225){return db[_0x89a7('0x1a')]['findAll']({'raw':_0x2c5ab4[_0x89a7('0x1b')]?_0x2c5ab4[_0x89a7('0x1b')][_0x89a7('0x1c')]===undefined?!![]:![]:!![],'where':_0x2c5ab4[_0x89a7('0x1b')]?_0x2c5ab4[_0x89a7('0x1b')][_0x89a7('0x1d')]||null:null,'attributes':[[db[_0x89a7('0x1e')]['fn'](_0x89a7('0x1f'),db['sequelize']['fn']('IF',db[_0x89a7('0x1e')][_0x89a7('0x20')](_0x89a7('0x21')))),_0x89a7('0x22')]]})[_0x89a7('0xf')](function(_0x556136){logger[_0x89a7('0x23')](_0x89a7('0x19'),_0x2c5ab4);logger[_0x89a7('0x12')]('GetVoiceQueueRtPauses',_0x2c5ab4,JSON[_0x89a7('0x24')](_0x556136));_0xece1dd(_0x556136);})[_0x89a7('0x18')](function(_0x427c46){logger[_0x89a7('0x14')](_0x89a7('0x19'),_0x427c46['message'],_0x2c5ab4);_0x128225(_0x1ab449['error'](0x1f4,_0x427c46[_0x89a7('0x16')]));});});};