c68ee28b5db1f6d1d1ca6d2ce95b3954fe9b6fd4
[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 _0xe370=['client','http','redis','socket.io-emitter','./userVoiceQueueRt.socket','register','request','then','UserVoiceQueueRt,\x20%s,\x20%s','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','info','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise'];(function(_0x20e95d,_0x1fc5f0){var _0xf6f68f=function(_0x4c6186){while(--_0x4c6186){_0x20e95d['push'](_0x20e95d['shift']());}};_0xf6f68f(++_0x1fc5f0);}(_0xe370,0x1b8));var _0x0e37=function(_0x101134,_0x1ed1d3){_0x101134=_0x101134-0x0;var _0xc47acc=_0xe370[_0x101134];return _0xc47acc;};'use strict';var _=require(_0x0e37('0x0'));var util=require(_0x0e37('0x1'));var moment=require(_0x0e37('0x2'));var BPromise=require(_0x0e37('0x3'));var rs=require(_0x0e37('0x4'));var fs=require('fs');var Redis=require(_0x0e37('0x5'));var db=require(_0x0e37('0x6'))['db'];var utils=require(_0x0e37('0x7'));var logger=require(_0x0e37('0x8'))('rpc');var config=require(_0x0e37('0x9'));var jayson=require(_0x0e37('0xa'));var client=jayson[_0x0e37('0xb')][_0x0e37('0xc')]({'port':0x232a});config[_0x0e37('0xd')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x0e37('0xe'))(new Redis(config[_0x0e37('0xd')]));require(_0x0e37('0xf'))[_0x0e37('0x10')](socket);function respondWithRpcPromise(_0x5d462d,_0x256750,_0x361228){return new BPromise(function(_0x3daba9,_0x348b7a){return client[_0x0e37('0x11')](_0x5d462d,_0x361228)[_0x0e37('0x12')](function(_0x36acda){logger['info'](_0x0e37('0x13'),_0x256750,'request\x20sent');logger[_0x0e37('0x14')](_0x0e37('0x15'),_0x256750,_0x0e37('0x16'),JSON['stringify'](_0x36acda));if(_0x36acda[_0x0e37('0x17')]){if(_0x36acda[_0x0e37('0x17')][_0x0e37('0x18')]===0x1f4){logger[_0x0e37('0x17')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x256750,_0x36acda[_0x0e37('0x17')][_0x0e37('0x19')]);return _0x348b7a(_0x36acda[_0x0e37('0x17')][_0x0e37('0x19')]);}logger[_0x0e37('0x17')](_0x0e37('0x13'),_0x256750,_0x36acda['error'][_0x0e37('0x19')]);return _0x3daba9(_0x36acda[_0x0e37('0x17')][_0x0e37('0x19')]);}else{logger[_0x0e37('0x1a')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x256750,_0x0e37('0x16'));_0x3daba9(_0x36acda[_0x0e37('0x1b')]['message']);}})[_0x0e37('0x1c')](function(_0x431a10){logger[_0x0e37('0x17')](_0x0e37('0x13'),_0x256750,_0x431a10);_0x348b7a(_0x431a10);});});}exports[_0x0e37('0x1d')]=function(_0x58be3f){var _0xd8df5f=this;return new Promise(function(_0x4e1d6d,_0x5a844d){return db[_0x0e37('0x1e')][_0x0e37('0x1f')]({'raw':_0x58be3f[_0x0e37('0x20')]?_0x58be3f[_0x0e37('0x20')][_0x0e37('0x21')]===undefined?!![]:![]:!![],'where':_0x58be3f[_0x0e37('0x20')]?_0x58be3f[_0x0e37('0x20')][_0x0e37('0x22')]||null:null,'attributes':[[db[_0x0e37('0x23')]['fn'](_0x0e37('0x24'),db[_0x0e37('0x23')]['fn']('IF',db[_0x0e37('0x23')][_0x0e37('0x25')](_0x0e37('0x26')))),_0x0e37('0x27')]]})[_0x0e37('0x12')](function(_0x316f91){logger['info'](_0x0e37('0x1d'),_0x58be3f);logger[_0x0e37('0x14')](_0x0e37('0x1d'),_0x58be3f,JSON[_0x0e37('0x28')](_0x316f91));_0x4e1d6d(_0x316f91);})['catch'](function(_0x2272e5){logger[_0x0e37('0x17')](_0x0e37('0x1d'),_0x2272e5['message'],_0x58be3f);_0x5a844d(_0xd8df5f['error'](0x1f4,_0x2272e5[_0x0e37('0x19')]));});});};