Built motion from commit (unavailable).|2.2.2
[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 _0x73d7=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','lodash','util','moment'];(function(_0x1ff012,_0x3d5c61){var _0xa49923=function(_0x52df2d){while(--_0x52df2d){_0x1ff012['push'](_0x1ff012['shift']());}};_0xa49923(++_0x3d5c61);}(_0x73d7,0x16f));var _0x773d=function(_0x31286e,_0x2d43cc){_0x31286e=_0x31286e-0x0;var _0x335723=_0x73d7[_0x31286e];return _0x335723;};'use strict';var _=require(_0x773d('0x0'));var util=require(_0x773d('0x1'));var moment=require(_0x773d('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x773d('0x3'));var db=require(_0x773d('0x4'))['db'];var utils=require(_0x773d('0x5'));var logger=require(_0x773d('0x6'))(_0x773d('0x7'));var config=require('../../config/environment');var jayson=require(_0x773d('0x8'));var client=jayson[_0x773d('0x9')][_0x773d('0xa')]({'port':0x232a});config[_0x773d('0xb')]=_['defaults'](config[_0x773d('0xb')],{'host':_0x773d('0xc'),'port':0x18eb});var socket=require(_0x773d('0xd'))(new Redis(config[_0x773d('0xb')]));require(_0x773d('0xe'))[_0x773d('0xf')](socket);function respondWithRpcPromise(_0x58cfa4,_0x11afae,_0x1059fe){return new BPromise(function(_0x200b0c,_0x5470f4){return client[_0x773d('0x10')](_0x58cfa4,_0x1059fe)[_0x773d('0x11')](function(_0x5edd18){logger[_0x773d('0x12')](_0x773d('0x13'),_0x11afae,_0x773d('0x14'));logger[_0x773d('0x15')](_0x773d('0x16'),_0x11afae,_0x773d('0x14'),JSON[_0x773d('0x17')](_0x5edd18));if(_0x5edd18[_0x773d('0x18')]){if(_0x5edd18['error']['code']===0x1f4){logger[_0x773d('0x18')](_0x773d('0x13'),_0x11afae,_0x5edd18['error'][_0x773d('0x19')]);return _0x5470f4(_0x5edd18[_0x773d('0x18')]['message']);}logger[_0x773d('0x18')](_0x773d('0x13'),_0x11afae,_0x5edd18[_0x773d('0x18')][_0x773d('0x19')]);return _0x200b0c(_0x5edd18[_0x773d('0x18')][_0x773d('0x19')]);}else{logger['info']('UserVoiceQueueRt,\x20%s,\x20%s',_0x11afae,_0x773d('0x14'));_0x200b0c(_0x5edd18[_0x773d('0x1a')][_0x773d('0x19')]);}})[_0x773d('0x1b')](function(_0x3b2b0c){logger[_0x773d('0x18')](_0x773d('0x13'),_0x11afae,_0x3b2b0c);_0x5470f4(_0x3b2b0c);});});}exports[_0x773d('0x1c')]=function(_0x3dec8b){var _0x35bf99=this;return new Promise(function(_0x2edc04,_0x458f2f){return db[_0x773d('0x1d')][_0x773d('0x1e')]({'raw':_0x3dec8b[_0x773d('0x1f')]?_0x3dec8b[_0x773d('0x1f')][_0x773d('0x20')]===undefined?!![]:![]:!![],'where':_0x3dec8b[_0x773d('0x1f')]?_0x3dec8b[_0x773d('0x1f')]['where']||null:null,'attributes':[[db[_0x773d('0x21')]['fn'](_0x773d('0x22'),db[_0x773d('0x21')]['fn']('IF',db[_0x773d('0x21')][_0x773d('0x23')](_0x773d('0x24')))),'outboundQueuePauses']]})[_0x773d('0x11')](function(_0x2f382e){logger[_0x773d('0x12')](_0x773d('0x1c'),_0x3dec8b);logger[_0x773d('0x15')](_0x773d('0x1c'),_0x3dec8b,JSON[_0x773d('0x17')](_0x2f382e));_0x2edc04(_0x2f382e);})['catch'](function(_0x45fb0e){logger[_0x773d('0x18')](_0x773d('0x1c'),_0x45fb0e[_0x773d('0x19')],_0x3dec8b);_0x458f2f(_0x35bf99[_0x773d('0x18')](0x1f4,_0x45fb0e['message']));});});};