e9cda40a3f4915247dc74afffa200eedbdd88cb8
[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 _0xccf0=['debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','options','raw','where','COUNT','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','GetVoiceQueueRtPauses','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','./userVoiceQueueRt.socket','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent'];(function(_0x2c0be1,_0x1e88f2){var _0x3d4bd2=function(_0x2b5497){while(--_0x2b5497){_0x2c0be1['push'](_0x2c0be1['shift']());}};_0x3d4bd2(++_0x1e88f2);}(_0xccf0,0x181));var _0x0ccf=function(_0x24f11a,_0x186852){_0x24f11a=_0x24f11a-0x0;var _0x46b685=_0xccf0[_0x24f11a];return _0x46b685;};'use strict';var _=require(_0x0ccf('0x0'));var util=require(_0x0ccf('0x1'));var moment=require(_0x0ccf('0x2'));var BPromise=require(_0x0ccf('0x3'));var rs=require(_0x0ccf('0x4'));var fs=require('fs');var Redis=require(_0x0ccf('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x0ccf('0x6'));var logger=require(_0x0ccf('0x7'))(_0x0ccf('0x8'));var config=require(_0x0ccf('0x9'));var jayson=require(_0x0ccf('0xa'));var client=jayson[_0x0ccf('0xb')]['http']({'port':0x232a});config[_0x0ccf('0xc')]=_[_0x0ccf('0xd')](config[_0x0ccf('0xc')],{'host':_0x0ccf('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0ccf('0xc')]));require(_0x0ccf('0xf'))[_0x0ccf('0x10')](socket);function respondWithRpcPromise(_0x1f167a,_0x59a106,_0x1200a3){return new BPromise(function(_0xe40e70,_0x221fa8){return client[_0x0ccf('0x11')](_0x1f167a,_0x1200a3)[_0x0ccf('0x12')](function(_0x29a05d){logger[_0x0ccf('0x13')](_0x0ccf('0x14'),_0x59a106,_0x0ccf('0x15'));logger[_0x0ccf('0x16')](_0x0ccf('0x17'),_0x59a106,_0x0ccf('0x15'),JSON['stringify'](_0x29a05d));if(_0x29a05d[_0x0ccf('0x18')]){if(_0x29a05d[_0x0ccf('0x18')][_0x0ccf('0x19')]===0x1f4){logger[_0x0ccf('0x18')](_0x0ccf('0x14'),_0x59a106,_0x29a05d[_0x0ccf('0x18')]['message']);return _0x221fa8(_0x29a05d[_0x0ccf('0x18')][_0x0ccf('0x1a')]);}logger[_0x0ccf('0x18')](_0x0ccf('0x14'),_0x59a106,_0x29a05d[_0x0ccf('0x18')][_0x0ccf('0x1a')]);return _0xe40e70(_0x29a05d[_0x0ccf('0x18')][_0x0ccf('0x1a')]);}else{logger[_0x0ccf('0x13')](_0x0ccf('0x14'),_0x59a106,_0x0ccf('0x15'));_0xe40e70(_0x29a05d[_0x0ccf('0x1b')][_0x0ccf('0x1a')]);}})[_0x0ccf('0x1c')](function(_0x72b978){logger[_0x0ccf('0x18')](_0x0ccf('0x14'),_0x59a106,_0x72b978);_0x221fa8(_0x72b978);});});}exports['GetVoiceQueueRtPauses']=function(_0xe263e9){var _0x1f4472=this;return new Promise(function(_0x2821f0,_0xb9bd3e){return db['UserVoiceQueueRt']['findAll']({'raw':_0xe263e9[_0x0ccf('0x1d')]?_0xe263e9[_0x0ccf('0x1d')][_0x0ccf('0x1e')]===undefined?!![]:![]:!![],'where':_0xe263e9[_0x0ccf('0x1d')]?_0xe263e9[_0x0ccf('0x1d')][_0x0ccf('0x1f')]||null:null,'attributes':[[db['sequelize']['fn'](_0x0ccf('0x20'),db['sequelize']['fn']('IF',db['sequelize']['literal'](_0x0ccf('0x21')))),_0x0ccf('0x22')]]})[_0x0ccf('0x12')](function(_0x32a80c){logger[_0x0ccf('0x13')](_0x0ccf('0x23'),_0xe263e9);logger[_0x0ccf('0x16')](_0x0ccf('0x23'),_0xe263e9,JSON[_0x0ccf('0x24')](_0x32a80c));_0x2821f0(_0x32a80c);})['catch'](function(_0x207f22){logger[_0x0ccf('0x18')](_0x0ccf('0x23'),_0x207f22[_0x0ccf('0x1a')],_0xe263e9);_0xb9bd3e(_0x1f4472[_0x0ccf('0x18')](0x1f4,_0x207f22[_0x0ccf('0x1a')]));});});};