c620a83923c1c6ec33f4f4a12800453bd850b7a0
[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 _0x377b=['request','then','info','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','UserVoiceQueueRt,\x20%s,\x20%s','message','result','catch','GetVoiceQueueRtPauses','options','raw','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','defaults','redis','localhost','./userVoiceQueueRt.socket'];(function(_0x2e9ad9,_0x14c1d2){var _0xb8d797=function(_0xaa63a6){while(--_0xaa63a6){_0x2e9ad9['push'](_0x2e9ad9['shift']());}};_0xb8d797(++_0x14c1d2);}(_0x377b,0x1dc));var _0xb377=function(_0x575e49,_0x5b65ce){_0x575e49=_0x575e49-0x0;var _0x25c47d=_0x377b[_0x575e49];return _0x25c47d;};'use strict';var _=require('lodash');var util=require(_0xb377('0x0'));var moment=require(_0xb377('0x1'));var BPromise=require(_0xb377('0x2'));var rs=require(_0xb377('0x3'));var fs=require('fs');var Redis=require(_0xb377('0x4'));var db=require(_0xb377('0x5'))['db'];var utils=require(_0xb377('0x6'));var logger=require(_0xb377('0x7'))('rpc');var config=require(_0xb377('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xb377('0x9')]['http']({'port':0x232a});config['redis']=_[_0xb377('0xa')](config[_0xb377('0xb')],{'host':_0xb377('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb377('0xb')]));require(_0xb377('0xd'))['register'](socket);function respondWithRpcPromise(_0x4dddb3,_0x2ac8c6,_0x3aa2f1){return new BPromise(function(_0x34b2e9,_0x298d0b){return client[_0xb377('0xe')](_0x4dddb3,_0x3aa2f1)[_0xb377('0xf')](function(_0x1fa4f3){logger[_0xb377('0x10')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x2ac8c6,'request\x20sent');logger[_0xb377('0x11')](_0xb377('0x12'),_0x2ac8c6,_0xb377('0x13'),JSON[_0xb377('0x14')](_0x1fa4f3));if(_0x1fa4f3[_0xb377('0x15')]){if(_0x1fa4f3['error'][_0xb377('0x16')]===0x1f4){logger[_0xb377('0x15')](_0xb377('0x17'),_0x2ac8c6,_0x1fa4f3['error'][_0xb377('0x18')]);return _0x298d0b(_0x1fa4f3[_0xb377('0x15')][_0xb377('0x18')]);}logger[_0xb377('0x15')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x2ac8c6,_0x1fa4f3[_0xb377('0x15')]['message']);return _0x34b2e9(_0x1fa4f3[_0xb377('0x15')][_0xb377('0x18')]);}else{logger[_0xb377('0x10')](_0xb377('0x17'),_0x2ac8c6,_0xb377('0x13'));_0x34b2e9(_0x1fa4f3[_0xb377('0x19')][_0xb377('0x18')]);}})[_0xb377('0x1a')](function(_0x4780ae){logger[_0xb377('0x15')](_0xb377('0x17'),_0x2ac8c6,_0x4780ae);_0x298d0b(_0x4780ae);});});}exports[_0xb377('0x1b')]=function(_0x223182){var _0x1de007=this;return new Promise(function(_0x476005,_0x3eed39){return db['UserVoiceQueueRt']['findAll']({'raw':_0x223182['options']?_0x223182[_0xb377('0x1c')][_0xb377('0x1d')]===undefined?!![]:![]:!![],'where':_0x223182[_0xb377('0x1c')]?_0x223182['options'][_0xb377('0x1e')]||null:null,'attributes':[[db[_0xb377('0x1f')]['fn'](_0xb377('0x20'),db[_0xb377('0x1f')]['fn']('IF',db[_0xb377('0x1f')][_0xb377('0x21')](_0xb377('0x22')))),'outboundQueuePauses']]})[_0xb377('0xf')](function(_0x39bc08){logger[_0xb377('0x10')](_0xb377('0x1b'),_0x223182);logger[_0xb377('0x11')](_0xb377('0x1b'),_0x223182,JSON[_0xb377('0x14')](_0x39bc08));_0x476005(_0x39bc08);})['catch'](function(_0x4baaea){logger[_0xb377('0x15')](_0xb377('0x1b'),_0x4baaea[_0xb377('0x18')],_0x223182);_0x3eed39(_0x1de007[_0xb377('0x15')](0x1f4,_0x4baaea[_0xb377('0x18')]));});});};