deeb9ee1eddd3455607affc5bc1228d1aabb2c14
[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 _0x9a6f=['COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','GetVoiceQueueRtPauses','stringify','util','moment','../../config/utils','../../config/logger','rpc','../../config/environment','http','defaults','localhost','socket.io-emitter','redis','./userVoiceQueueRt.socket','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','error','code','message','UserVoiceQueueRt','options','sequelize'];(function(_0x5abbca,_0x595973){var _0x1a31c7=function(_0x3430ec){while(--_0x3430ec){_0x5abbca['push'](_0x5abbca['shift']());}};_0x1a31c7(++_0x595973);}(_0x9a6f,0x1a6));var _0xf9a6=function(_0xf61129,_0x523668){_0xf61129=_0xf61129-0x0;var _0xefa38a=_0x9a6f[_0xf61129];return _0xefa38a;};'use strict';var _=require('lodash');var util=require(_0xf9a6('0x0'));var moment=require(_0xf9a6('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xf9a6('0x2'));var logger=require(_0xf9a6('0x3'))(_0xf9a6('0x4'));var config=require(_0xf9a6('0x5'));var jayson=require('jayson/promise');var client=jayson['client'][_0xf9a6('0x6')]({'port':0x232a});config['redis']=_[_0xf9a6('0x7')](config['redis'],{'host':_0xf9a6('0x8'),'port':0x18eb});var socket=require(_0xf9a6('0x9'))(new Redis(config[_0xf9a6('0xa')]));require(_0xf9a6('0xb'))[_0xf9a6('0xc')](socket);function respondWithRpcPromise(_0x4645af,_0x200cd6,_0x5e4149){return new BPromise(function(_0x414061,_0xdceeb7){return client[_0xf9a6('0xd')](_0x4645af,_0x5e4149)[_0xf9a6('0xe')](function(_0x49df7a){logger[_0xf9a6('0xf')](_0xf9a6('0x10'),_0x200cd6,_0xf9a6('0x11'));logger[_0xf9a6('0x12')](_0xf9a6('0x13'),_0x200cd6,_0xf9a6('0x11'),JSON['stringify'](_0x49df7a));if(_0x49df7a[_0xf9a6('0x14')]){if(_0x49df7a[_0xf9a6('0x14')][_0xf9a6('0x15')]===0x1f4){logger[_0xf9a6('0x14')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x200cd6,_0x49df7a[_0xf9a6('0x14')]['message']);return _0xdceeb7(_0x49df7a[_0xf9a6('0x14')]['message']);}logger[_0xf9a6('0x14')](_0xf9a6('0x10'),_0x200cd6,_0x49df7a[_0xf9a6('0x14')][_0xf9a6('0x16')]);return _0x414061(_0x49df7a[_0xf9a6('0x14')][_0xf9a6('0x16')]);}else{logger[_0xf9a6('0xf')](_0xf9a6('0x10'),_0x200cd6,_0xf9a6('0x11'));_0x414061(_0x49df7a['result']['message']);}})['catch'](function(_0xa3e991){logger['error'](_0xf9a6('0x10'),_0x200cd6,_0xa3e991);_0xdceeb7(_0xa3e991);});});}exports['GetVoiceQueueRtPauses']=function(_0x25ba03){var _0x333db7=this;return new Promise(function(_0x5b56c3,_0x838577){return db[_0xf9a6('0x17')]['findAll']({'raw':_0x25ba03['options']?_0x25ba03[_0xf9a6('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x25ba03[_0xf9a6('0x18')]?_0x25ba03[_0xf9a6('0x18')]['where']||null:null,'attributes':[[db[_0xf9a6('0x19')]['fn'](_0xf9a6('0x1a'),db[_0xf9a6('0x19')]['fn']('IF',db[_0xf9a6('0x19')][_0xf9a6('0x1b')](_0xf9a6('0x1c')))),_0xf9a6('0x1d')]]})[_0xf9a6('0xe')](function(_0xeca072){logger['info'](_0xf9a6('0x1e'),_0x25ba03);logger[_0xf9a6('0x12')]('GetVoiceQueueRtPauses',_0x25ba03,JSON[_0xf9a6('0x1f')](_0xeca072));_0x5b56c3(_0xeca072);})['catch'](function(_0x10da80){logger[_0xf9a6('0x14')](_0xf9a6('0x1e'),_0x10da80[_0xf9a6('0x16')],_0x25ba03);_0x838577(_0x333db7[_0xf9a6('0x14')](0x1f4,_0x10da80[_0xf9a6('0x16')]));});});};