Built motion from commit (unavailable).|2.5.14
[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 _0xb0bc=['raw','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','then','catch','moment','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','./userVoiceQueueRt.socket','register','request','info','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','UserVoiceQueueRt,\x20%s,\x20%s','message','GetVoiceQueueRtPauses','options'];(function(_0x147fa5,_0x25d300){var _0x53bc5d=function(_0x579f73){while(--_0x579f73){_0x147fa5['push'](_0x147fa5['shift']());}};_0x53bc5d(++_0x25d300);}(_0xb0bc,0x82));var _0xcb0b=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0xb0bc[_0xa464c9];return _0x3d73c4;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xcb0b('0x0'));var BPromise=require('bluebird');var rs=require(_0xcb0b('0x1'));var fs=require('fs');var Redis=require(_0xcb0b('0x2'));var db=require(_0xcb0b('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xcb0b('0x4'));var config=require(_0xcb0b('0x5'));var jayson=require(_0xcb0b('0x6'));var client=jayson[_0xcb0b('0x7')]['http']({'port':0x232a});config[_0xcb0b('0x8')]=_[_0xcb0b('0x9')](config[_0xcb0b('0x8')],{'host':_0xcb0b('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xcb0b('0x8')]));require(_0xcb0b('0xb'))[_0xcb0b('0xc')](socket);function respondWithRpcPromise(_0x1f9f05,_0x2a3fe7,_0x1e35db){return new BPromise(function(_0x2237c6,_0x2d2285){return client[_0xcb0b('0xd')](_0x1f9f05,_0x1e35db)['then'](function(_0x92aa13){logger[_0xcb0b('0xe')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x2a3fe7,_0xcb0b('0xf'));logger[_0xcb0b('0x10')](_0xcb0b('0x11'),_0x2a3fe7,'request\x20sent',JSON[_0xcb0b('0x12')](_0x92aa13));if(_0x92aa13[_0xcb0b('0x13')]){if(_0x92aa13[_0xcb0b('0x13')][_0xcb0b('0x14')]===0x1f4){logger[_0xcb0b('0x13')](_0xcb0b('0x15'),_0x2a3fe7,_0x92aa13['error'][_0xcb0b('0x16')]);return _0x2d2285(_0x92aa13[_0xcb0b('0x13')][_0xcb0b('0x16')]);}logger[_0xcb0b('0x13')](_0xcb0b('0x15'),_0x2a3fe7,_0x92aa13[_0xcb0b('0x13')][_0xcb0b('0x16')]);return _0x2237c6(_0x92aa13[_0xcb0b('0x13')]['message']);}else{logger[_0xcb0b('0xe')](_0xcb0b('0x15'),_0x2a3fe7,_0xcb0b('0xf'));_0x2237c6(_0x92aa13['result'][_0xcb0b('0x16')]);}})['catch'](function(_0x405a9d){logger[_0xcb0b('0x13')](_0xcb0b('0x15'),_0x2a3fe7,_0x405a9d);_0x2d2285(_0x405a9d);});});}exports[_0xcb0b('0x17')]=function(_0x5a1efe){var _0x3040c8=this;return new Promise(function(_0x569d57,_0x3bcb17){return db['UserVoiceQueueRt']['findAll']({'raw':_0x5a1efe[_0xcb0b('0x18')]?_0x5a1efe[_0xcb0b('0x18')][_0xcb0b('0x19')]===undefined?!![]:![]:!![],'where':_0x5a1efe['options']?_0x5a1efe[_0xcb0b('0x18')]['where']||null:null,'attributes':[[db['sequelize']['fn']('COUNT',db['sequelize']['fn']('IF',db[_0xcb0b('0x1a')][_0xcb0b('0x1b')](_0xcb0b('0x1c')))),'outboundQueuePauses']]})[_0xcb0b('0x1d')](function(_0x2c4a6a){logger[_0xcb0b('0xe')](_0xcb0b('0x17'),_0x5a1efe);logger[_0xcb0b('0x10')]('GetVoiceQueueRtPauses',_0x5a1efe,JSON['stringify'](_0x2c4a6a));_0x569d57(_0x2c4a6a);})[_0xcb0b('0x1e')](function(_0x1f0375){logger['error'](_0xcb0b('0x17'),_0x1f0375['message'],_0x5a1efe);_0x3bcb17(_0x3040c8[_0xcb0b('0x13')](0x1f4,_0x1f0375[_0xcb0b('0x16')]));});});};