Built motion from commit (unavailable).|2.3.1
[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 _0x5c25=['GetVoiceQueueRtPauses','findAll','options','raw','where','COUNT','sequelize','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','stringify','catch','lodash','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','redis','defaults','socket.io-emitter','register','request','then','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','request\x20sent','code','error','message','UserVoiceQueueRt,\x20%s,\x20%s','info','result'];(function(_0x5b3820,_0x51889c){var _0x442af8=function(_0x597ee1){while(--_0x597ee1){_0x5b3820['push'](_0x5b3820['shift']());}};_0x442af8(++_0x51889c);}(_0x5c25,0x181));var _0x55c2=function(_0x498e1c,_0xd545ca){_0x498e1c=_0x498e1c-0x0;var _0xb11ed3=_0x5c25[_0x498e1c];return _0xb11ed3;};'use strict';var _=require(_0x55c2('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x55c2('0x1'));var db=require(_0x55c2('0x2'))['db'];var utils=require(_0x55c2('0x3'));var logger=require('../../config/logger')(_0x55c2('0x4'));var config=require(_0x55c2('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x55c2('0x6')][_0x55c2('0x7')]({'port':0x232a});config[_0x55c2('0x8')]=_[_0x55c2('0x9')](config[_0x55c2('0x8')],{'host':'localhost','port':0x18eb});var socket=require(_0x55c2('0xa'))(new Redis(config[_0x55c2('0x8')]));require('./userVoiceQueueRt.socket')[_0x55c2('0xb')](socket);function respondWithRpcPromise(_0x26c0ba,_0x48999c,_0x294528){return new BPromise(function(_0x1ebaf3,_0x5a850c){return client[_0x55c2('0xc')](_0x26c0ba,_0x294528)[_0x55c2('0xd')](function(_0x41c4d0){logger['info']('UserVoiceQueueRt,\x20%s,\x20%s',_0x48999c,'request\x20sent');logger[_0x55c2('0xe')](_0x55c2('0xf'),_0x48999c,_0x55c2('0x10'),JSON['stringify'](_0x41c4d0));if(_0x41c4d0['error']){if(_0x41c4d0['error'][_0x55c2('0x11')]===0x1f4){logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x48999c,_0x41c4d0[_0x55c2('0x12')][_0x55c2('0x13')]);return _0x5a850c(_0x41c4d0[_0x55c2('0x12')][_0x55c2('0x13')]);}logger[_0x55c2('0x12')](_0x55c2('0x14'),_0x48999c,_0x41c4d0[_0x55c2('0x12')]['message']);return _0x1ebaf3(_0x41c4d0[_0x55c2('0x12')][_0x55c2('0x13')]);}else{logger[_0x55c2('0x15')](_0x55c2('0x14'),_0x48999c,_0x55c2('0x10'));_0x1ebaf3(_0x41c4d0[_0x55c2('0x16')]['message']);}})['catch'](function(_0x1a5955){logger[_0x55c2('0x12')](_0x55c2('0x14'),_0x48999c,_0x1a5955);_0x5a850c(_0x1a5955);});});}exports[_0x55c2('0x17')]=function(_0x427c81){var _0x13a8c2=this;return new Promise(function(_0x5e180d,_0x90ecd1){return db['UserVoiceQueueRt'][_0x55c2('0x18')]({'raw':_0x427c81[_0x55c2('0x19')]?_0x427c81[_0x55c2('0x19')][_0x55c2('0x1a')]===undefined?!![]:![]:!![],'where':_0x427c81[_0x55c2('0x19')]?_0x427c81[_0x55c2('0x19')][_0x55c2('0x1b')]||null:null,'attributes':[[db['sequelize']['fn'](_0x55c2('0x1c'),db[_0x55c2('0x1d')]['fn']('IF',db[_0x55c2('0x1d')]['literal'](_0x55c2('0x1e')))),_0x55c2('0x1f')]]})['then'](function(_0x1e2881){logger[_0x55c2('0x15')]('GetVoiceQueueRtPauses',_0x427c81);logger[_0x55c2('0xe')](_0x55c2('0x17'),_0x427c81,JSON[_0x55c2('0x20')](_0x1e2881));_0x5e180d(_0x1e2881);})[_0x55c2('0x21')](function(_0xe18847){logger[_0x55c2('0x12')]('GetVoiceQueueRtPauses',_0xe18847[_0x55c2('0x13')],_0x427c81);_0x90ecd1(_0x13a8c2[_0x55c2('0x12')](0x1f4,_0xe18847[_0x55c2('0x13')]));});});};