Built motion from commit (unavailable).|2.5.10
[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 _0xa54e=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','socket.io-emitter','./userVoiceQueueRt.socket','register','then','UserVoiceQueueRt,\x20%s,\x20%s','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','UserVoiceQueueRt','findAll','options','raw','where','COUNT','sequelize','outboundQueuePauses','GetVoiceQueueRtPauses','util','bluebird','randomstring'];(function(_0x5b14df,_0x2d6d66){var _0x1285e8=function(_0xbc19ce){while(--_0xbc19ce){_0x5b14df['push'](_0x5b14df['shift']());}};_0x1285e8(++_0x2d6d66);}(_0xa54e,0x194));var _0xea54=function(_0x212fcc,_0x1a8867){_0x212fcc=_0x212fcc-0x0;var _0x4d8190=_0xa54e[_0x212fcc];return _0x4d8190;};'use strict';var _=require('lodash');var util=require(_0xea54('0x0'));var moment=require('moment');var BPromise=require(_0xea54('0x1'));var rs=require(_0xea54('0x2'));var fs=require('fs');var Redis=require(_0xea54('0x3'));var db=require(_0xea54('0x4'))['db'];var utils=require(_0xea54('0x5'));var logger=require(_0xea54('0x6'))(_0xea54('0x7'));var config=require(_0xea54('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xea54('0x9')][_0xea54('0xa')]({'port':0x232a});config[_0xea54('0xb')]=_[_0xea54('0xc')](config[_0xea54('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0xea54('0xd'))(new Redis(config[_0xea54('0xb')]));require(_0xea54('0xe'))[_0xea54('0xf')](socket);function respondWithRpcPromise(_0x2de712,_0x235c61,_0xc331da){return new BPromise(function(_0x1a6cc3,_0x361e7d){return client['request'](_0x2de712,_0xc331da)[_0xea54('0x10')](function(_0x46b2e2){logger['info'](_0xea54('0x11'),_0x235c61,'request\x20sent');logger[_0xea54('0x12')](_0xea54('0x13'),_0x235c61,_0xea54('0x14'),JSON[_0xea54('0x15')](_0x46b2e2));if(_0x46b2e2['error']){if(_0x46b2e2[_0xea54('0x16')][_0xea54('0x17')]===0x1f4){logger[_0xea54('0x16')](_0xea54('0x11'),_0x235c61,_0x46b2e2[_0xea54('0x16')][_0xea54('0x18')]);return _0x361e7d(_0x46b2e2[_0xea54('0x16')][_0xea54('0x18')]);}logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x235c61,_0x46b2e2[_0xea54('0x16')]['message']);return _0x1a6cc3(_0x46b2e2[_0xea54('0x16')][_0xea54('0x18')]);}else{logger[_0xea54('0x19')](_0xea54('0x11'),_0x235c61,_0xea54('0x14'));_0x1a6cc3(_0x46b2e2[_0xea54('0x1a')]['message']);}})[_0xea54('0x1b')](function(_0x24ede3){logger[_0xea54('0x16')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x235c61,_0x24ede3);_0x361e7d(_0x24ede3);});});}exports['GetVoiceQueueRtPauses']=function(_0x321430){var _0x5c10c1=this;return new Promise(function(_0x1c8b3c,_0x47d282){return db[_0xea54('0x1c')][_0xea54('0x1d')]({'raw':_0x321430[_0xea54('0x1e')]?_0x321430[_0xea54('0x1e')][_0xea54('0x1f')]===undefined?!![]:![]:!![],'where':_0x321430['options']?_0x321430['options'][_0xea54('0x20')]||null:null,'attributes':[[db['sequelize']['fn'](_0xea54('0x21'),db['sequelize']['fn']('IF',db[_0xea54('0x22')]['literal']('`paused`\x20=\x201,\x201,\x20null'))),_0xea54('0x23')]]})[_0xea54('0x10')](function(_0x228cf0){logger[_0xea54('0x19')](_0xea54('0x24'),_0x321430);logger['debug'](_0xea54('0x24'),_0x321430,JSON[_0xea54('0x15')](_0x228cf0));_0x1c8b3c(_0x228cf0);})['catch'](function(_0x1e0f29){logger[_0xea54('0x16')]('GetVoiceQueueRtPauses',_0x1e0f29[_0xea54('0x18')],_0x321430);_0x47d282(_0x5c10c1[_0xea54('0x16')](0x1f4,_0x1e0f29['message']));});});};