a008662ed0919d00a77c619d945e346d30c1c41b
[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 _0xccc9=['util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','defaults','localhost','redis','./userVoiceQueueRt.socket','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','error','code','message','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','catch','lodash'];(function(_0x228641,_0x25d636){var _0x5d5d78=function(_0x4d5c6c){while(--_0x4d5c6c){_0x228641['push'](_0x228641['shift']());}};_0x5d5d78(++_0x25d636);}(_0xccc9,0x1d3));var _0x9ccc=function(_0x139862,_0x15a6c1){_0x139862=_0x139862-0x0;var _0x55ed8d=_0xccc9[_0x139862];return _0x55ed8d;};'use strict';var _=require(_0x9ccc('0x0'));var util=require(_0x9ccc('0x1'));var moment=require(_0x9ccc('0x2'));var BPromise=require(_0x9ccc('0x3'));var rs=require(_0x9ccc('0x4'));var fs=require('fs');var Redis=require(_0x9ccc('0x5'));var db=require(_0x9ccc('0x6'))['db'];var utils=require(_0x9ccc('0x7'));var logger=require(_0x9ccc('0x8'))('rpc');var config=require(_0x9ccc('0x9'));var jayson=require(_0x9ccc('0xa'));var client=jayson['client'][_0x9ccc('0xb')]({'port':0x232a});config['redis']=_[_0x9ccc('0xc')](config['redis'],{'host':_0x9ccc('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9ccc('0xe')]));require(_0x9ccc('0xf'))['register'](socket);function respondWithRpcPromise(_0x165654,_0x83911a,_0x1b947f){return new BPromise(function(_0x374ef2,_0xd365b5){return client[_0x9ccc('0x10')](_0x165654,_0x1b947f)[_0x9ccc('0x11')](function(_0x1c9cd7){logger[_0x9ccc('0x12')](_0x9ccc('0x13'),_0x83911a,_0x9ccc('0x14'));logger[_0x9ccc('0x15')](_0x9ccc('0x16'),_0x83911a,_0x9ccc('0x14'),JSON['stringify'](_0x1c9cd7));if(_0x1c9cd7[_0x9ccc('0x17')]){if(_0x1c9cd7[_0x9ccc('0x17')][_0x9ccc('0x18')]===0x1f4){logger[_0x9ccc('0x17')](_0x9ccc('0x13'),_0x83911a,_0x1c9cd7[_0x9ccc('0x17')][_0x9ccc('0x19')]);return _0xd365b5(_0x1c9cd7[_0x9ccc('0x17')]['message']);}logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x83911a,_0x1c9cd7[_0x9ccc('0x17')][_0x9ccc('0x19')]);return _0x374ef2(_0x1c9cd7[_0x9ccc('0x17')][_0x9ccc('0x19')]);}else{logger[_0x9ccc('0x12')](_0x9ccc('0x13'),_0x83911a,'request\x20sent');_0x374ef2(_0x1c9cd7['result'][_0x9ccc('0x19')]);}})['catch'](function(_0xa57000){logger[_0x9ccc('0x17')](_0x9ccc('0x13'),_0x83911a,_0xa57000);_0xd365b5(_0xa57000);});});}exports[_0x9ccc('0x1a')]=function(_0x4069e3){var _0x533d30=this;return new Promise(function(_0x114579,_0x47ec2a){return db[_0x9ccc('0x1b')][_0x9ccc('0x1c')]({'raw':_0x4069e3[_0x9ccc('0x1d')]?_0x4069e3['options']['raw']===undefined?!![]:![]:!![],'where':_0x4069e3[_0x9ccc('0x1d')]?_0x4069e3[_0x9ccc('0x1d')]['where']||null:null,'attributes':[[db[_0x9ccc('0x1e')]['fn'](_0x9ccc('0x1f'),db[_0x9ccc('0x1e')]['fn']('IF',db[_0x9ccc('0x1e')][_0x9ccc('0x20')](_0x9ccc('0x21')))),_0x9ccc('0x22')]]})[_0x9ccc('0x11')](function(_0x174e0f){logger['info'](_0x9ccc('0x1a'),_0x4069e3);logger[_0x9ccc('0x15')](_0x9ccc('0x1a'),_0x4069e3,JSON['stringify'](_0x174e0f));_0x114579(_0x174e0f);})[_0x9ccc('0x23')](function(_0x3710f5){logger['error'](_0x9ccc('0x1a'),_0x3710f5['message'],_0x4069e3);_0x47ec2a(_0x533d30[_0x9ccc('0x17')](0x1f4,_0x3710f5[_0x9ccc('0x19')]));});});};