dec1f26d0e08600397464a30e5e62d78035ceced
[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 _0x7b78=['client','http','redis','defaults','localhost','./userVoiceQueueRt.socket','register','request','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','error','code','message','info','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','where','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','then','stringify','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise'];(function(_0x3b816c,_0x18fabc){var _0x445513=function(_0x19a96c){while(--_0x19a96c){_0x3b816c['push'](_0x3b816c['shift']());}};_0x445513(++_0x18fabc);}(_0x7b78,0x81));var _0x87b7=function(_0x6ca0aa,_0x1c3791){_0x6ca0aa=_0x6ca0aa-0x0;var _0x440087=_0x7b78[_0x6ca0aa];return _0x440087;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x87b7('0x0'));var BPromise=require('bluebird');var rs=require(_0x87b7('0x1'));var fs=require('fs');var Redis=require(_0x87b7('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x87b7('0x3'));var logger=require(_0x87b7('0x4'))(_0x87b7('0x5'));var config=require('../../config/environment');var jayson=require(_0x87b7('0x6'));var client=jayson[_0x87b7('0x7')][_0x87b7('0x8')]({'port':0x232a});config[_0x87b7('0x9')]=_[_0x87b7('0xa')](config['redis'],{'host':_0x87b7('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x87b7('0x9')]));require(_0x87b7('0xc'))[_0x87b7('0xd')](socket);function respondWithRpcPromise(_0x3243ff,_0x3ac1dc,_0x3105c1){return new BPromise(function(_0x3b1c81,_0x146f76){return client[_0x87b7('0xe')](_0x3243ff,_0x3105c1)['then'](function(_0x5ab3f5){logger['info'](_0x87b7('0xf'),_0x3ac1dc,_0x87b7('0x10'));logger[_0x87b7('0x11')]('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x3ac1dc,_0x87b7('0x10'),JSON['stringify'](_0x5ab3f5));if(_0x5ab3f5['error']){if(_0x5ab3f5[_0x87b7('0x12')][_0x87b7('0x13')]===0x1f4){logger[_0x87b7('0x12')](_0x87b7('0xf'),_0x3ac1dc,_0x5ab3f5[_0x87b7('0x12')][_0x87b7('0x14')]);return _0x146f76(_0x5ab3f5[_0x87b7('0x12')][_0x87b7('0x14')]);}logger[_0x87b7('0x12')](_0x87b7('0xf'),_0x3ac1dc,_0x5ab3f5[_0x87b7('0x12')][_0x87b7('0x14')]);return _0x3b1c81(_0x5ab3f5['error'][_0x87b7('0x14')]);}else{logger[_0x87b7('0x15')](_0x87b7('0xf'),_0x3ac1dc,_0x87b7('0x10'));_0x3b1c81(_0x5ab3f5['result']['message']);}})[_0x87b7('0x16')](function(_0x540c5b){logger[_0x87b7('0x12')](_0x87b7('0xf'),_0x3ac1dc,_0x540c5b);_0x146f76(_0x540c5b);});});}exports[_0x87b7('0x17')]=function(_0x44103b){var _0x100eca=this;return new Promise(function(_0x45b321,_0x3fc2d8){return db[_0x87b7('0x18')][_0x87b7('0x19')]({'raw':_0x44103b['options']?_0x44103b['options']['raw']===undefined?!![]:![]:!![],'where':_0x44103b[_0x87b7('0x1a')]?_0x44103b['options'][_0x87b7('0x1b')]||null:null,'attributes':[[db[_0x87b7('0x1c')]['fn']('COUNT',db[_0x87b7('0x1c')]['fn']('IF',db[_0x87b7('0x1c')][_0x87b7('0x1d')](_0x87b7('0x1e')))),_0x87b7('0x1f')]]})[_0x87b7('0x20')](function(_0x2356ea){logger[_0x87b7('0x15')](_0x87b7('0x17'),_0x44103b);logger['debug'](_0x87b7('0x17'),_0x44103b,JSON[_0x87b7('0x21')](_0x2356ea));_0x45b321(_0x2356ea);})[_0x87b7('0x16')](function(_0xffa32e){logger[_0x87b7('0x12')](_0x87b7('0x17'),_0xffa32e[_0x87b7('0x14')],_0x44103b);_0x3fc2d8(_0x100eca[_0x87b7('0x12')](0x1f4,_0xffa32e[_0x87b7('0x14')]));});});};