7ed8d58345c59edd1961b95b2390bdccd2753943
[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 _0xb92a=['UserVoiceQueueRt,\x20%s,\x20%s','message','info','result','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','catch','lodash','util','moment','bluebird','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./userVoiceQueueRt.socket','register','then','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x128bf8,_0x19b03b){var _0x1a28d3=function(_0x3ea3bf){while(--_0x3ea3bf){_0x128bf8['push'](_0x128bf8['shift']());}};_0x1a28d3(++_0x19b03b);}(_0xb92a,0x10a));var _0xab92=function(_0x2deb73,_0x1228f9){_0x2deb73=_0x2deb73-0x0;var _0x4e2da5=_0xb92a[_0x2deb73];return _0x4e2da5;};'use strict';var _=require(_0xab92('0x0'));var util=require(_0xab92('0x1'));var moment=require(_0xab92('0x2'));var BPromise=require(_0xab92('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xab92('0x4'));var logger=require(_0xab92('0x5'))(_0xab92('0x6'));var config=require(_0xab92('0x7'));var jayson=require(_0xab92('0x8'));var client=jayson[_0xab92('0x9')][_0xab92('0xa')]({'port':0x232a});config[_0xab92('0xb')]=_[_0xab92('0xc')](config['redis'],{'host':_0xab92('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xab92('0xe'))[_0xab92('0xf')](socket);function respondWithRpcPromise(_0x507458,_0xd5043e,_0x70d1d8){return new BPromise(function(_0xe4105f,_0x1cd4ea){return client['request'](_0x507458,_0x70d1d8)[_0xab92('0x10')](function(_0x12a455){logger['info']('UserVoiceQueueRt,\x20%s,\x20%s',_0xd5043e,_0xab92('0x11'));logger[_0xab92('0x12')](_0xab92('0x13'),_0xd5043e,'request\x20sent',JSON[_0xab92('0x14')](_0x12a455));if(_0x12a455['error']){if(_0x12a455['error']['code']===0x1f4){logger[_0xab92('0x15')](_0xab92('0x16'),_0xd5043e,_0x12a455[_0xab92('0x15')][_0xab92('0x17')]);return _0x1cd4ea(_0x12a455[_0xab92('0x15')]['message']);}logger[_0xab92('0x15')](_0xab92('0x16'),_0xd5043e,_0x12a455[_0xab92('0x15')]['message']);return _0xe4105f(_0x12a455[_0xab92('0x15')]['message']);}else{logger[_0xab92('0x18')](_0xab92('0x16'),_0xd5043e,'request\x20sent');_0xe4105f(_0x12a455[_0xab92('0x19')]['message']);}})['catch'](function(_0x3d9cca){logger['error'](_0xab92('0x16'),_0xd5043e,_0x3d9cca);_0x1cd4ea(_0x3d9cca);});});}exports[_0xab92('0x1a')]=function(_0x3a9f11){var _0x2984e3=this;return new Promise(function(_0x522732,_0xdae58f){return db[_0xab92('0x1b')][_0xab92('0x1c')]({'raw':_0x3a9f11['options']?_0x3a9f11[_0xab92('0x1d')][_0xab92('0x1e')]===undefined?!![]:![]:!![],'where':_0x3a9f11[_0xab92('0x1d')]?_0x3a9f11[_0xab92('0x1d')]['where']||null:null,'attributes':[[db['sequelize']['fn']('COUNT',db[_0xab92('0x1f')]['fn']('IF',db[_0xab92('0x1f')][_0xab92('0x20')](_0xab92('0x21')))),_0xab92('0x22')]]})[_0xab92('0x10')](function(_0x5c151d){logger[_0xab92('0x18')](_0xab92('0x1a'),_0x3a9f11);logger[_0xab92('0x12')]('GetVoiceQueueRtPauses',_0x3a9f11,JSON[_0xab92('0x14')](_0x5c151d));_0x522732(_0x5c151d);})[_0xab92('0x23')](function(_0x3344e2){logger[_0xab92('0x15')]('GetVoiceQueueRtPauses',_0x3344e2[_0xab92('0x17')],_0x3a9f11);_0xdae58f(_0x2984e3['error'](0x1f4,_0x3344e2[_0xab92('0x17')]));});});};