Built motion from commit (unavailable).|2.5.29
[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 _0xbb6e=['defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','request','UserVoiceQueueRt,\x20%s,\x20%s','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','options','raw','where','sequelize','COUNT','literal','outboundQueuePauses','then','lodash','util','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis'];(function(_0xe471e8,_0x59a29b){var _0x1dc1c8=function(_0x111e22){while(--_0x111e22){_0xe471e8['push'](_0xe471e8['shift']());}};_0x1dc1c8(++_0x59a29b);}(_0xbb6e,0xb7));var _0xebb6=function(_0x48a71c,_0x2a21e5){_0x48a71c=_0x48a71c-0x0;var _0x5f374d=_0xbb6e[_0x48a71c];return _0x5f374d;};'use strict';var _=require(_0xebb6('0x0'));var util=require(_0xebb6('0x1'));var moment=require('moment');var BPromise=require(_0xebb6('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xebb6('0x3'));var db=require(_0xebb6('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xebb6('0x5'))(_0xebb6('0x6'));var config=require(_0xebb6('0x7'));var jayson=require(_0xebb6('0x8'));var client=jayson[_0xebb6('0x9')][_0xebb6('0xa')]({'port':0x232a});config[_0xebb6('0xb')]=_[_0xebb6('0xc')](config[_0xebb6('0xb')],{'host':_0xebb6('0xd'),'port':0x18eb});var socket=require(_0xebb6('0xe'))(new Redis(config[_0xebb6('0xb')]));require(_0xebb6('0xf'))[_0xebb6('0x10')](socket);function respondWithRpcPromise(_0x5c967d,_0x21f30b,_0xb972a6){return new BPromise(function(_0x3bd8d1,_0x523f3a){return client[_0xebb6('0x11')](_0x5c967d,_0xb972a6)['then'](function(_0x4b0c69){logger['info'](_0xebb6('0x12'),_0x21f30b,'request\x20sent');logger[_0xebb6('0x13')](_0xebb6('0x14'),_0x21f30b,_0xebb6('0x15'),JSON[_0xebb6('0x16')](_0x4b0c69));if(_0x4b0c69['error']){if(_0x4b0c69[_0xebb6('0x17')][_0xebb6('0x18')]===0x1f4){logger['error'](_0xebb6('0x12'),_0x21f30b,_0x4b0c69[_0xebb6('0x17')][_0xebb6('0x19')]);return _0x523f3a(_0x4b0c69[_0xebb6('0x17')][_0xebb6('0x19')]);}logger['error'](_0xebb6('0x12'),_0x21f30b,_0x4b0c69[_0xebb6('0x17')]['message']);return _0x3bd8d1(_0x4b0c69[_0xebb6('0x17')][_0xebb6('0x19')]);}else{logger[_0xebb6('0x1a')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x21f30b,'request\x20sent');_0x3bd8d1(_0x4b0c69[_0xebb6('0x1b')][_0xebb6('0x19')]);}})[_0xebb6('0x1c')](function(_0x2f55e5){logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x21f30b,_0x2f55e5);_0x523f3a(_0x2f55e5);});});}exports[_0xebb6('0x1d')]=function(_0x2b45d1){var _0x22e9a4=this;return new Promise(function(_0x348a68,_0x5eac41){return db[_0xebb6('0x1e')]['findAll']({'raw':_0x2b45d1[_0xebb6('0x1f')]?_0x2b45d1[_0xebb6('0x1f')][_0xebb6('0x20')]===undefined?!![]:![]:!![],'where':_0x2b45d1['options']?_0x2b45d1[_0xebb6('0x1f')][_0xebb6('0x21')]||null:null,'attributes':[[db[_0xebb6('0x22')]['fn'](_0xebb6('0x23'),db[_0xebb6('0x22')]['fn']('IF',db[_0xebb6('0x22')][_0xebb6('0x24')]('`paused`\x20=\x201,\x201,\x20null'))),_0xebb6('0x25')]]})[_0xebb6('0x26')](function(_0x54f960){logger[_0xebb6('0x1a')](_0xebb6('0x1d'),_0x2b45d1);logger[_0xebb6('0x13')](_0xebb6('0x1d'),_0x2b45d1,JSON[_0xebb6('0x16')](_0x54f960));_0x348a68(_0x54f960);})['catch'](function(_0xd91910){logger[_0xebb6('0x17')]('GetVoiceQueueRtPauses',_0xd91910[_0xebb6('0x19')],_0x2b45d1);_0x5eac41(_0x22e9a4[_0xebb6('0x17')](0x1f4,_0xd91910[_0xebb6('0x19')]));});});};