Built motion from commit eddce310.|2.6.12
[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 _0x9b5a=['../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','catch','util','moment','ioredis','../../config/utils','rpc'];(function(_0x44216d,_0x4938a7){var _0xeca523=function(_0x11faf1){while(--_0x11faf1){_0x44216d['push'](_0x44216d['shift']());}};_0xeca523(++_0x4938a7);}(_0x9b5a,0x148));var _0xa9b5=function(_0x5812c3,_0x3009c3){_0x5812c3=_0x5812c3-0x0;var _0x5ea060=_0x9b5a[_0x5812c3];return _0x5ea060;};'use strict';var _=require('lodash');var util=require(_0xa9b5('0x0'));var moment=require(_0xa9b5('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa9b5('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xa9b5('0x3'));var logger=require('../../config/logger')(_0xa9b5('0x4'));var config=require(_0xa9b5('0x5'));var jayson=require(_0xa9b5('0x6'));var client=jayson[_0xa9b5('0x7')][_0xa9b5('0x8')]({'port':0x232a});config[_0xa9b5('0x9')]=_[_0xa9b5('0xa')](config[_0xa9b5('0x9')],{'host':_0xa9b5('0xb'),'port':0x18eb});var socket=require(_0xa9b5('0xc'))(new Redis(config[_0xa9b5('0x9')]));require(_0xa9b5('0xd'))[_0xa9b5('0xe')](socket);function respondWithRpcPromise(_0x4fba72,_0x25c8f7,_0x3a611d){return new BPromise(function(_0x2fc8c5,_0x31321d){return client[_0xa9b5('0xf')](_0x4fba72,_0x3a611d)[_0xa9b5('0x10')](function(_0x41d564){logger[_0xa9b5('0x11')](_0xa9b5('0x12'),_0x25c8f7,_0xa9b5('0x13'));logger[_0xa9b5('0x14')](_0xa9b5('0x15'),_0x25c8f7,'request\x20sent',JSON[_0xa9b5('0x16')](_0x41d564));if(_0x41d564['error']){if(_0x41d564[_0xa9b5('0x17')][_0xa9b5('0x18')]===0x1f4){logger[_0xa9b5('0x17')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x25c8f7,_0x41d564[_0xa9b5('0x17')]['message']);return _0x31321d(_0x41d564['error']['message']);}logger[_0xa9b5('0x17')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x25c8f7,_0x41d564['error'][_0xa9b5('0x19')]);return _0x2fc8c5(_0x41d564[_0xa9b5('0x17')]['message']);}else{logger[_0xa9b5('0x11')](_0xa9b5('0x12'),_0x25c8f7,_0xa9b5('0x13'));_0x2fc8c5(_0x41d564[_0xa9b5('0x1a')][_0xa9b5('0x19')]);}})['catch'](function(_0x240389){logger[_0xa9b5('0x17')](_0xa9b5('0x12'),_0x25c8f7,_0x240389);_0x31321d(_0x240389);});});}exports[_0xa9b5('0x1b')]=function(_0x4b6a28){var _0x323513=this;return new Promise(function(_0x4b5ff7,_0x5c6425){return db[_0xa9b5('0x1c')][_0xa9b5('0x1d')]({'raw':_0x4b6a28['options']?_0x4b6a28[_0xa9b5('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x4b6a28[_0xa9b5('0x1e')]?_0x4b6a28['options'][_0xa9b5('0x1f')]||null:null,'attributes':[[db[_0xa9b5('0x20')]['fn'](_0xa9b5('0x21'),db['sequelize']['fn']('IF',db[_0xa9b5('0x20')][_0xa9b5('0x22')](_0xa9b5('0x23')))),'outboundQueuePauses']]})[_0xa9b5('0x10')](function(_0x4d361d){logger[_0xa9b5('0x11')]('GetVoiceQueueRtPauses',_0x4b6a28);logger[_0xa9b5('0x14')](_0xa9b5('0x1b'),_0x4b6a28,JSON['stringify'](_0x4d361d));_0x4b5ff7(_0x4d361d);})[_0xa9b5('0x24')](function(_0x559859){logger['error'](_0xa9b5('0x1b'),_0x559859[_0xa9b5('0x19')],_0x4b6a28);_0x5c6425(_0x323513[_0xa9b5('0x17')](0x1f4,_0x559859[_0xa9b5('0x19')]));});});};