Built motion from commit (unavailable).|2.5.21
[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 _0xd21a=['code','message','result','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','raw','options','where','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','debug','catch','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','stringify','error'];(function(_0x1a40f2,_0x1a5fc9){var _0x3e5eee=function(_0x5c542b){while(--_0x5c542b){_0x1a40f2['push'](_0x1a40f2['shift']());}};_0x3e5eee(++_0x1a5fc9);}(_0xd21a,0xd2));var _0xad21=function(_0x442f5b,_0x39d79d){_0x442f5b=_0x442f5b-0x0;var _0x19fd96=_0xd21a[_0x442f5b];return _0x19fd96;};'use strict';var _=require(_0xad21('0x0'));var util=require(_0xad21('0x1'));var moment=require('moment');var BPromise=require(_0xad21('0x2'));var rs=require(_0xad21('0x3'));var fs=require('fs');var Redis=require(_0xad21('0x4'));var db=require(_0xad21('0x5'))['db'];var utils=require(_0xad21('0x6'));var logger=require(_0xad21('0x7'))(_0xad21('0x8'));var config=require(_0xad21('0x9'));var jayson=require(_0xad21('0xa'));var client=jayson[_0xad21('0xb')][_0xad21('0xc')]({'port':0x232a});config[_0xad21('0xd')]=_[_0xad21('0xe')](config[_0xad21('0xd')],{'host':_0xad21('0xf'),'port':0x18eb});var socket=require(_0xad21('0x10'))(new Redis(config[_0xad21('0xd')]));require(_0xad21('0x11'))[_0xad21('0x12')](socket);function respondWithRpcPromise(_0x518246,_0x51775f,_0x5f5be2){return new BPromise(function(_0x3b0be3,_0x54a07e){return client['request'](_0x518246,_0x5f5be2)['then'](function(_0x4a10e7){logger[_0xad21('0x13')](_0xad21('0x14'),_0x51775f,_0xad21('0x15'));logger['debug']('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x51775f,_0xad21('0x15'),JSON[_0xad21('0x16')](_0x4a10e7));if(_0x4a10e7[_0xad21('0x17')]){if(_0x4a10e7[_0xad21('0x17')][_0xad21('0x18')]===0x1f4){logger[_0xad21('0x17')](_0xad21('0x14'),_0x51775f,_0x4a10e7[_0xad21('0x17')][_0xad21('0x19')]);return _0x54a07e(_0x4a10e7[_0xad21('0x17')][_0xad21('0x19')]);}logger['error'](_0xad21('0x14'),_0x51775f,_0x4a10e7[_0xad21('0x17')][_0xad21('0x19')]);return _0x3b0be3(_0x4a10e7[_0xad21('0x17')]['message']);}else{logger[_0xad21('0x13')](_0xad21('0x14'),_0x51775f,_0xad21('0x15'));_0x3b0be3(_0x4a10e7[_0xad21('0x1a')][_0xad21('0x19')]);}})['catch'](function(_0x1e437d){logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x51775f,_0x1e437d);_0x54a07e(_0x1e437d);});});}exports[_0xad21('0x1b')]=function(_0x53e552){var _0x2b5929=this;return new Promise(function(_0x3b92e8,_0xcb9e1){return db[_0xad21('0x1c')][_0xad21('0x1d')]({'raw':_0x53e552['options']?_0x53e552['options'][_0xad21('0x1e')]===undefined?!![]:![]:!![],'where':_0x53e552[_0xad21('0x1f')]?_0x53e552[_0xad21('0x1f')][_0xad21('0x20')]||null:null,'attributes':[[db[_0xad21('0x21')]['fn']('COUNT',db[_0xad21('0x21')]['fn']('IF',db[_0xad21('0x21')][_0xad21('0x22')](_0xad21('0x23')))),_0xad21('0x24')]]})['then'](function(_0x215f74){logger[_0xad21('0x13')](_0xad21('0x1b'),_0x53e552);logger[_0xad21('0x25')]('GetVoiceQueueRtPauses',_0x53e552,JSON[_0xad21('0x16')](_0x215f74));_0x3b92e8(_0x215f74);})[_0xad21('0x26')](function(_0xa7b1e2){logger[_0xad21('0x17')](_0xad21('0x1b'),_0xa7b1e2[_0xad21('0x19')],_0x53e552);_0xcb9e1(_0x2b5929['error'](0x1f4,_0xa7b1e2['message']));});});};