21ce15879daafd0235486d5c7166b4454328062e
[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 _0x04fb=['./userVoiceQueueRt.socket','register','request','info','UserVoiceQueueRt,\x20%s,\x20%s','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','catch','GetVoiceQueueRtPauses','findAll','options','raw','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','then','debug','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','socket.io-emitter'];(function(_0x13060e,_0x5564ce){var _0x1a6418=function(_0x4149c6){while(--_0x4149c6){_0x13060e['push'](_0x13060e['shift']());}};_0x1a6418(++_0x5564ce);}(_0x04fb,0x65));var _0xb04f=function(_0x3afb92,_0x44a61a){_0x3afb92=_0x3afb92-0x0;var _0x52a91a=_0x04fb[_0x3afb92];return _0x52a91a;};'use strict';var _=require(_0xb04f('0x0'));var util=require(_0xb04f('0x1'));var moment=require(_0xb04f('0x2'));var BPromise=require(_0xb04f('0x3'));var rs=require(_0xb04f('0x4'));var fs=require('fs');var Redis=require(_0xb04f('0x5'));var db=require(_0xb04f('0x6'))['db'];var utils=require(_0xb04f('0x7'));var logger=require(_0xb04f('0x8'))(_0xb04f('0x9'));var config=require(_0xb04f('0xa'));var jayson=require('jayson/promise');var client=jayson[_0xb04f('0xb')][_0xb04f('0xc')]({'port':0x232a});config['redis']=_['defaults'](config[_0xb04f('0xd')],{'host':_0xb04f('0xe'),'port':0x18eb});var socket=require(_0xb04f('0xf'))(new Redis(config[_0xb04f('0xd')]));require(_0xb04f('0x10'))[_0xb04f('0x11')](socket);function respondWithRpcPromise(_0x2bdd6b,_0x2747e7,_0xe28acf){return new BPromise(function(_0x3f1d72,_0x50b7d1){return client[_0xb04f('0x12')](_0x2bdd6b,_0xe28acf)['then'](function(_0x4e59b0){logger[_0xb04f('0x13')](_0xb04f('0x14'),_0x2747e7,'request\x20sent');logger['debug'](_0xb04f('0x15'),_0x2747e7,_0xb04f('0x16'),JSON[_0xb04f('0x17')](_0x4e59b0));if(_0x4e59b0[_0xb04f('0x18')]){if(_0x4e59b0[_0xb04f('0x18')]['code']===0x1f4){logger[_0xb04f('0x18')](_0xb04f('0x14'),_0x2747e7,_0x4e59b0[_0xb04f('0x18')][_0xb04f('0x19')]);return _0x50b7d1(_0x4e59b0['error']['message']);}logger['error'](_0xb04f('0x14'),_0x2747e7,_0x4e59b0[_0xb04f('0x18')]['message']);return _0x3f1d72(_0x4e59b0[_0xb04f('0x18')][_0xb04f('0x19')]);}else{logger[_0xb04f('0x13')](_0xb04f('0x14'),_0x2747e7,'request\x20sent');_0x3f1d72(_0x4e59b0['result'][_0xb04f('0x19')]);}})[_0xb04f('0x1a')](function(_0x4421c1){logger[_0xb04f('0x18')](_0xb04f('0x14'),_0x2747e7,_0x4421c1);_0x50b7d1(_0x4421c1);});});}exports[_0xb04f('0x1b')]=function(_0x18d90e){var _0x3fd300=this;return new Promise(function(_0x5adf67,_0x10f536){return db['UserVoiceQueueRt'][_0xb04f('0x1c')]({'raw':_0x18d90e['options']?_0x18d90e[_0xb04f('0x1d')][_0xb04f('0x1e')]===undefined?!![]:![]:!![],'where':_0x18d90e[_0xb04f('0x1d')]?_0x18d90e[_0xb04f('0x1d')][_0xb04f('0x1f')]||null:null,'attributes':[[db[_0xb04f('0x20')]['fn'](_0xb04f('0x21'),db['sequelize']['fn']('IF',db[_0xb04f('0x20')][_0xb04f('0x22')](_0xb04f('0x23')))),_0xb04f('0x24')]]})[_0xb04f('0x25')](function(_0x2af5e1){logger[_0xb04f('0x13')](_0xb04f('0x1b'),_0x18d90e);logger[_0xb04f('0x26')](_0xb04f('0x1b'),_0x18d90e,JSON['stringify'](_0x2af5e1));_0x5adf67(_0x2af5e1);})[_0xb04f('0x1a')](function(_0x1ecad0){logger[_0xb04f('0x18')]('GetVoiceQueueRtPauses',_0x1ecad0[_0xb04f('0x19')],_0x18d90e);_0x10f536(_0x3fd300['error'](0x1f4,_0x1ecad0[_0xb04f('0x19')]));});});};