Built motion from commit (unavailable).|2.5.27
[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 _0xad50=['debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','./userVoiceQueueRt.socket','register','then','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent'];(function(_0x365be9,_0x3c88b9){var _0x185c12=function(_0xbadbbf){while(--_0xbadbbf){_0x365be9['push'](_0x365be9['shift']());}};_0x185c12(++_0x3c88b9);}(_0xad50,0xf0));var _0x0ad5=function(_0x17882c,_0x4b964b){_0x17882c=_0x17882c-0x0;var _0x355a59=_0xad50[_0x17882c];return _0x355a59;};'use strict';var _=require(_0x0ad5('0x0'));var util=require('util');var moment=require(_0x0ad5('0x1'));var BPromise=require(_0x0ad5('0x2'));var rs=require(_0x0ad5('0x3'));var fs=require('fs');var Redis=require(_0x0ad5('0x4'));var db=require(_0x0ad5('0x5'))['db'];var utils=require(_0x0ad5('0x6'));var logger=require('../../config/logger')(_0x0ad5('0x7'));var config=require(_0x0ad5('0x8'));var jayson=require(_0x0ad5('0x9'));var client=jayson[_0x0ad5('0xa')]['http']({'port':0x232a});config[_0x0ad5('0xb')]=_[_0x0ad5('0xc')](config[_0x0ad5('0xb')],{'host':_0x0ad5('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x0ad5('0xe'))[_0x0ad5('0xf')](socket);function respondWithRpcPromise(_0x4fed94,_0x5b07d5,_0x5d46d6){return new BPromise(function(_0x3fd10c,_0x4c1c77){return client['request'](_0x4fed94,_0x5d46d6)[_0x0ad5('0x10')](function(_0x2f82a2){logger['info'](_0x0ad5('0x11'),_0x5b07d5,_0x0ad5('0x12'));logger[_0x0ad5('0x13')](_0x0ad5('0x14'),_0x5b07d5,_0x0ad5('0x12'),JSON[_0x0ad5('0x15')](_0x2f82a2));if(_0x2f82a2[_0x0ad5('0x16')]){if(_0x2f82a2['error'][_0x0ad5('0x17')]===0x1f4){logger[_0x0ad5('0x16')](_0x0ad5('0x11'),_0x5b07d5,_0x2f82a2[_0x0ad5('0x16')][_0x0ad5('0x18')]);return _0x4c1c77(_0x2f82a2[_0x0ad5('0x16')][_0x0ad5('0x18')]);}logger[_0x0ad5('0x16')](_0x0ad5('0x11'),_0x5b07d5,_0x2f82a2[_0x0ad5('0x16')][_0x0ad5('0x18')]);return _0x3fd10c(_0x2f82a2[_0x0ad5('0x16')][_0x0ad5('0x18')]);}else{logger[_0x0ad5('0x19')](_0x0ad5('0x11'),_0x5b07d5,'request\x20sent');_0x3fd10c(_0x2f82a2[_0x0ad5('0x1a')]['message']);}})[_0x0ad5('0x1b')](function(_0x13923d){logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x5b07d5,_0x13923d);_0x4c1c77(_0x13923d);});});}exports[_0x0ad5('0x1c')]=function(_0x374b2f){var _0x51fb32=this;return new Promise(function(_0x342516,_0x19ece3){return db[_0x0ad5('0x1d')][_0x0ad5('0x1e')]({'raw':_0x374b2f['options']?_0x374b2f['options']['raw']===undefined?!![]:![]:!![],'where':_0x374b2f['options']?_0x374b2f[_0x0ad5('0x1f')]['where']||null:null,'attributes':[[db[_0x0ad5('0x20')]['fn'](_0x0ad5('0x21'),db['sequelize']['fn']('IF',db[_0x0ad5('0x20')][_0x0ad5('0x22')](_0x0ad5('0x23')))),_0x0ad5('0x24')]]})[_0x0ad5('0x10')](function(_0x4f432c){logger[_0x0ad5('0x19')](_0x0ad5('0x1c'),_0x374b2f);logger['debug'](_0x0ad5('0x1c'),_0x374b2f,JSON['stringify'](_0x4f432c));_0x342516(_0x4f432c);})[_0x0ad5('0x1b')](function(_0x39c06a){logger[_0x0ad5('0x16')](_0x0ad5('0x1c'),_0x39c06a[_0x0ad5('0x18')],_0x374b2f);_0x19ece3(_0x51fb32[_0x0ad5('0x16')](0x1f4,_0x39c06a[_0x0ad5('0x18')]));});});};