Built motion from commit 3c2ce842.|2.6.31
[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 _0x2981=['code','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','raw','options','where','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','util','moment','bluebird','randomstring','../../mysqldb','rpc','jayson/promise','http','redis','defaults','localhost','./userVoiceQueueRt.socket','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x555d12,_0x4894be){var _0x47c35c=function(_0x3b8106){while(--_0x3b8106){_0x555d12['push'](_0x555d12['shift']());}};_0x47c35c(++_0x4894be);}(_0x2981,0x11d));var _0x1298=function(_0x36a96a,_0x1eb790){_0x36a96a=_0x36a96a-0x0;var _0x50de5b=_0x2981[_0x36a96a];return _0x50de5b;};'use strict';var _=require('lodash');var util=require(_0x1298('0x0'));var moment=require(_0x1298('0x1'));var BPromise=require(_0x1298('0x2'));var rs=require(_0x1298('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1298('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x1298('0x5'));var config=require('../../config/environment');var jayson=require(_0x1298('0x6'));var client=jayson['client'][_0x1298('0x7')]({'port':0x232a});config[_0x1298('0x8')]=_[_0x1298('0x9')](config[_0x1298('0x8')],{'host':_0x1298('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x1298('0xb'))['register'](socket);function respondWithRpcPromise(_0x3609f6,_0x14b21e,_0x48391a){return new BPromise(function(_0x2dbe5d,_0x27a1a8){return client[_0x1298('0xc')](_0x3609f6,_0x48391a)[_0x1298('0xd')](function(_0x34b0b3){logger[_0x1298('0xe')](_0x1298('0xf'),_0x14b21e,_0x1298('0x10'));logger[_0x1298('0x11')](_0x1298('0x12'),_0x14b21e,_0x1298('0x10'),JSON[_0x1298('0x13')](_0x34b0b3));if(_0x34b0b3['error']){if(_0x34b0b3[_0x1298('0x14')][_0x1298('0x15')]===0x1f4){logger[_0x1298('0x14')](_0x1298('0xf'),_0x14b21e,_0x34b0b3[_0x1298('0x14')][_0x1298('0x16')]);return _0x27a1a8(_0x34b0b3[_0x1298('0x14')][_0x1298('0x16')]);}logger[_0x1298('0x14')](_0x1298('0xf'),_0x14b21e,_0x34b0b3[_0x1298('0x14')][_0x1298('0x16')]);return _0x2dbe5d(_0x34b0b3[_0x1298('0x14')]['message']);}else{logger[_0x1298('0xe')](_0x1298('0xf'),_0x14b21e,_0x1298('0x10'));_0x2dbe5d(_0x34b0b3[_0x1298('0x17')][_0x1298('0x16')]);}})[_0x1298('0x18')](function(_0xec11c){logger[_0x1298('0x14')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x14b21e,_0xec11c);_0x27a1a8(_0xec11c);});});}exports[_0x1298('0x19')]=function(_0x16f6c3){var _0xfa1a3f=this;return new Promise(function(_0x9f4126,_0x15669f){return db[_0x1298('0x1a')]['findAll']({'raw':_0x16f6c3['options']?_0x16f6c3['options'][_0x1298('0x1b')]===undefined?!![]:![]:!![],'where':_0x16f6c3[_0x1298('0x1c')]?_0x16f6c3[_0x1298('0x1c')][_0x1298('0x1d')]||null:null,'attributes':[[db[_0x1298('0x1e')]['fn']('COUNT',db[_0x1298('0x1e')]['fn']('IF',db[_0x1298('0x1e')][_0x1298('0x1f')](_0x1298('0x20')))),_0x1298('0x21')]]})[_0x1298('0xd')](function(_0x31800e){logger['info'](_0x1298('0x19'),_0x16f6c3);logger[_0x1298('0x11')]('GetVoiceQueueRtPauses',_0x16f6c3,JSON[_0x1298('0x13')](_0x31800e));_0x9f4126(_0x31800e);})[_0x1298('0x18')](function(_0x31f501){logger['error'](_0x1298('0x19'),_0x31f501[_0x1298('0x16')],_0x16f6c3);_0x15669f(_0xfa1a3f[_0x1298('0x14')](0x1f4,_0x31f501[_0x1298('0x16')]));});});};