Built motion from commit e6806ed6.|2.6.0
[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 _0x87c3=['../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','request','then','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','where','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc'];(function(_0x39f119,_0xc67edd){var _0x36d66c=function(_0x55b146){while(--_0x55b146){_0x39f119['push'](_0x39f119['shift']());}};_0x36d66c(++_0xc67edd);}(_0x87c3,0x14e));var _0x387c=function(_0x3ebc25,_0x2ee551){_0x3ebc25=_0x3ebc25-0x0;var _0x53b1c2=_0x87c3[_0x3ebc25];return _0x53b1c2;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x387c('0x0'));var BPromise=require(_0x387c('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x387c('0x2'));var db=require(_0x387c('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x387c('0x4'))(_0x387c('0x5'));var config=require(_0x387c('0x6'));var jayson=require(_0x387c('0x7'));var client=jayson[_0x387c('0x8')][_0x387c('0x9')]({'port':0x232a});config[_0x387c('0xa')]=_[_0x387c('0xb')](config[_0x387c('0xa')],{'host':_0x387c('0xc'),'port':0x18eb});var socket=require(_0x387c('0xd'))(new Redis(config[_0x387c('0xa')]));require('./userVoiceQueueRt.socket')[_0x387c('0xe')](socket);function respondWithRpcPromise(_0x148ee3,_0x3faadd,_0x3131dc){return new BPromise(function(_0xe672d,_0x5cac04){return client[_0x387c('0xf')](_0x148ee3,_0x3131dc)[_0x387c('0x10')](function(_0x3231f5){logger['info'](_0x387c('0x11'),_0x3faadd,_0x387c('0x12'));logger['debug']('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x3faadd,'request\x20sent',JSON[_0x387c('0x13')](_0x3231f5));if(_0x3231f5[_0x387c('0x14')]){if(_0x3231f5[_0x387c('0x14')]['code']===0x1f4){logger[_0x387c('0x14')](_0x387c('0x11'),_0x3faadd,_0x3231f5[_0x387c('0x14')][_0x387c('0x15')]);return _0x5cac04(_0x3231f5[_0x387c('0x14')][_0x387c('0x15')]);}logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x3faadd,_0x3231f5[_0x387c('0x14')][_0x387c('0x15')]);return _0xe672d(_0x3231f5[_0x387c('0x14')][_0x387c('0x15')]);}else{logger['info'](_0x387c('0x11'),_0x3faadd,_0x387c('0x12'));_0xe672d(_0x3231f5[_0x387c('0x16')][_0x387c('0x15')]);}})[_0x387c('0x17')](function(_0x2ad626){logger[_0x387c('0x14')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x3faadd,_0x2ad626);_0x5cac04(_0x2ad626);});});}exports[_0x387c('0x18')]=function(_0x516f52){var _0x2bf4dd=this;return new Promise(function(_0x4fcb14,_0x295f26){return db[_0x387c('0x19')][_0x387c('0x1a')]({'raw':_0x516f52[_0x387c('0x1b')]?_0x516f52[_0x387c('0x1b')][_0x387c('0x1c')]===undefined?!![]:![]:!![],'where':_0x516f52['options']?_0x516f52[_0x387c('0x1b')][_0x387c('0x1d')]||null:null,'attributes':[[db[_0x387c('0x1e')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x387c('0x1e')][_0x387c('0x1f')](_0x387c('0x20')))),_0x387c('0x21')]]})[_0x387c('0x10')](function(_0x47e71a){logger['info'](_0x387c('0x18'),_0x516f52);logger['debug'](_0x387c('0x18'),_0x516f52,JSON[_0x387c('0x13')](_0x47e71a));_0x4fcb14(_0x47e71a);})[_0x387c('0x17')](function(_0x8fb839){logger['error'](_0x387c('0x18'),_0x8fb839[_0x387c('0x15')],_0x516f52);_0x295f26(_0x2bf4dd[_0x387c('0x14')](0x1f4,_0x8fb839[_0x387c('0x15')]));});});};