Built motion from commit f7863d46.|2.5.41
[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 _0xaec5=['request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','sequelize','literal','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','defaults','redis','socket.io-emitter','./userVoiceQueueRt.socket','register','request','info','UserVoiceQueueRt,\x20%s,\x20%s'];(function(_0x488ce6,_0x1110a0){var _0x3e0661=function(_0x312caa){while(--_0x312caa){_0x488ce6['push'](_0x488ce6['shift']());}};_0x3e0661(++_0x1110a0);}(_0xaec5,0xbf));var _0x5aec=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xaec5[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x5aec('0x0'));var util=require('util');var moment=require(_0x5aec('0x1'));var BPromise=require('bluebird');var rs=require(_0x5aec('0x2'));var fs=require('fs');var Redis=require(_0x5aec('0x3'));var db=require(_0x5aec('0x4'))['db'];var utils=require(_0x5aec('0x5'));var logger=require(_0x5aec('0x6'))(_0x5aec('0x7'));var config=require('../../config/environment');var jayson=require(_0x5aec('0x8'));var client=jayson[_0x5aec('0x9')][_0x5aec('0xa')]({'port':0x232a});config['redis']=_[_0x5aec('0xb')](config[_0x5aec('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x5aec('0xd'))(new Redis(config[_0x5aec('0xc')]));require(_0x5aec('0xe'))[_0x5aec('0xf')](socket);function respondWithRpcPromise(_0x447964,_0x98df28,_0x1effb1){return new BPromise(function(_0x4ab972,_0x66fbd9){return client[_0x5aec('0x10')](_0x447964,_0x1effb1)['then'](function(_0x3b8674){logger[_0x5aec('0x11')](_0x5aec('0x12'),_0x98df28,_0x5aec('0x13'));logger[_0x5aec('0x14')](_0x5aec('0x15'),_0x98df28,'request\x20sent',JSON[_0x5aec('0x16')](_0x3b8674));if(_0x3b8674[_0x5aec('0x17')]){if(_0x3b8674['error'][_0x5aec('0x18')]===0x1f4){logger[_0x5aec('0x17')](_0x5aec('0x12'),_0x98df28,_0x3b8674[_0x5aec('0x17')]['message']);return _0x66fbd9(_0x3b8674[_0x5aec('0x17')][_0x5aec('0x19')]);}logger[_0x5aec('0x17')](_0x5aec('0x12'),_0x98df28,_0x3b8674[_0x5aec('0x17')][_0x5aec('0x19')]);return _0x4ab972(_0x3b8674[_0x5aec('0x17')][_0x5aec('0x19')]);}else{logger['info'](_0x5aec('0x12'),_0x98df28,'request\x20sent');_0x4ab972(_0x3b8674[_0x5aec('0x1a')][_0x5aec('0x19')]);}})[_0x5aec('0x1b')](function(_0x4932a8){logger[_0x5aec('0x17')](_0x5aec('0x12'),_0x98df28,_0x4932a8);_0x66fbd9(_0x4932a8);});});}exports[_0x5aec('0x1c')]=function(_0xbe224e){var _0x1acca8=this;return new Promise(function(_0x310a13,_0xc75308){return db[_0x5aec('0x1d')][_0x5aec('0x1e')]({'raw':_0xbe224e[_0x5aec('0x1f')]?_0xbe224e[_0x5aec('0x1f')][_0x5aec('0x20')]===undefined?!![]:![]:!![],'where':_0xbe224e['options']?_0xbe224e[_0x5aec('0x1f')]['where']||null:null,'attributes':[[db[_0x5aec('0x21')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x5aec('0x21')][_0x5aec('0x22')]('`paused`\x20=\x201,\x201,\x20null'))),'outboundQueuePauses']]})['then'](function(_0x49eecd){logger[_0x5aec('0x11')](_0x5aec('0x1c'),_0xbe224e);logger[_0x5aec('0x14')](_0x5aec('0x1c'),_0xbe224e,JSON[_0x5aec('0x16')](_0x49eecd));_0x310a13(_0x49eecd);})[_0x5aec('0x1b')](function(_0x20f072){logger['error'](_0x5aec('0x1c'),_0x20f072[_0x5aec('0x19')],_0xbe224e);_0xc75308(_0x1acca8['error'](0x1f4,_0x20f072[_0x5aec('0x19')]));});});};