Built motion from commit 43538d75.|2.5.35
[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 _0x23b8=['client','http','defaults','redis','localhost','./userVoiceQueueRt.socket','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','code','error','message','request\x20sent','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','debug','stringify','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise'];(function(_0x378fde,_0xedbaa){var _0x1b1798=function(_0x2bc61d){while(--_0x2bc61d){_0x378fde['push'](_0x378fde['shift']());}};_0x1b1798(++_0xedbaa);}(_0x23b8,0x169));var _0x823b=function(_0x2ae22a,_0x4fe753){_0x2ae22a=_0x2ae22a-0x0;var _0x286a82=_0x23b8[_0x2ae22a];return _0x286a82;};'use strict';var _=require(_0x823b('0x0'));var util=require(_0x823b('0x1'));var moment=require(_0x823b('0x2'));var BPromise=require('bluebird');var rs=require(_0x823b('0x3'));var fs=require('fs');var Redis=require(_0x823b('0x4'));var db=require(_0x823b('0x5'))['db'];var utils=require(_0x823b('0x6'));var logger=require('../../config/logger')(_0x823b('0x7'));var config=require('../../config/environment');var jayson=require(_0x823b('0x8'));var client=jayson[_0x823b('0x9')][_0x823b('0xa')]({'port':0x232a});config['redis']=_[_0x823b('0xb')](config[_0x823b('0xc')],{'host':_0x823b('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x823b('0xc')]));require(_0x823b('0xe'))['register'](socket);function respondWithRpcPromise(_0x2f4ebd,_0x408d84,_0x272611){return new BPromise(function(_0x282727,_0x47b80f){return client[_0x823b('0xf')](_0x2f4ebd,_0x272611)[_0x823b('0x10')](function(_0x235586){logger[_0x823b('0x11')](_0x823b('0x12'),_0x408d84,'request\x20sent');logger['debug'](_0x823b('0x13'),_0x408d84,'request\x20sent',JSON['stringify'](_0x235586));if(_0x235586['error']){if(_0x235586['error'][_0x823b('0x14')]===0x1f4){logger[_0x823b('0x15')](_0x823b('0x12'),_0x408d84,_0x235586[_0x823b('0x15')]['message']);return _0x47b80f(_0x235586['error'][_0x823b('0x16')]);}logger['error'](_0x823b('0x12'),_0x408d84,_0x235586[_0x823b('0x15')]['message']);return _0x282727(_0x235586[_0x823b('0x15')]['message']);}else{logger[_0x823b('0x11')](_0x823b('0x12'),_0x408d84,_0x823b('0x17'));_0x282727(_0x235586[_0x823b('0x18')][_0x823b('0x16')]);}})[_0x823b('0x19')](function(_0x2abcfc){logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x408d84,_0x2abcfc);_0x47b80f(_0x2abcfc);});});}exports[_0x823b('0x1a')]=function(_0x2e90ee){var _0xf89b8f=this;return new Promise(function(_0x4a2736,_0x491e47){return db[_0x823b('0x1b')][_0x823b('0x1c')]({'raw':_0x2e90ee[_0x823b('0x1d')]?_0x2e90ee['options'][_0x823b('0x1e')]===undefined?!![]:![]:!![],'where':_0x2e90ee[_0x823b('0x1d')]?_0x2e90ee[_0x823b('0x1d')]['where']||null:null,'attributes':[[db[_0x823b('0x1f')]['fn']('COUNT',db[_0x823b('0x1f')]['fn']('IF',db[_0x823b('0x1f')][_0x823b('0x20')](_0x823b('0x21')))),_0x823b('0x22')]]})[_0x823b('0x10')](function(_0x15f935){logger[_0x823b('0x11')](_0x823b('0x1a'),_0x2e90ee);logger[_0x823b('0x23')](_0x823b('0x1a'),_0x2e90ee,JSON[_0x823b('0x24')](_0x15f935));_0x4a2736(_0x15f935);})[_0x823b('0x19')](function(_0xf3b29e){logger[_0x823b('0x15')](_0x823b('0x1a'),_0xf3b29e[_0x823b('0x16')],_0x2e90ee);_0x491e47(_0xf89b8f[_0x823b('0x15')](0x1f4,_0xf3b29e[_0x823b('0x16')]));});});};