Built motion from commit (unavailable).|2.5.22
[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 _0x39b7=['ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','redis','defaults','./userVoiceQueueRt.socket','request','then','info','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','UserVoiceQueueRt,\x20%s,\x20%s','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','COUNT','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','lodash','util','moment','randomstring'];(function(_0x361e9c,_0x47bdbf){var _0x13c601=function(_0x28a5f8){while(--_0x28a5f8){_0x361e9c['push'](_0x361e9c['shift']());}};_0x13c601(++_0x47bdbf);}(_0x39b7,0x12e));var _0x739b=function(_0x2642eb,_0x38d2ef){_0x2642eb=_0x2642eb-0x0;var _0x2758ed=_0x39b7[_0x2642eb];return _0x2758ed;};'use strict';var _=require(_0x739b('0x0'));var util=require(_0x739b('0x1'));var moment=require(_0x739b('0x2'));var BPromise=require('bluebird');var rs=require(_0x739b('0x3'));var fs=require('fs');var Redis=require(_0x739b('0x4'));var db=require(_0x739b('0x5'))['db'];var utils=require(_0x739b('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0x739b('0x7'));var jayson=require(_0x739b('0x8'));var client=jayson[_0x739b('0x9')][_0x739b('0xa')]({'port':0x232a});config[_0x739b('0xb')]=_[_0x739b('0xc')](config[_0x739b('0xb')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x739b('0xb')]));require(_0x739b('0xd'))['register'](socket);function respondWithRpcPromise(_0x2cfacb,_0x48a4d7,_0x5dae44){return new BPromise(function(_0x387d95,_0x60033a){return client[_0x739b('0xe')](_0x2cfacb,_0x5dae44)[_0x739b('0xf')](function(_0x494b2c){logger[_0x739b('0x10')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x48a4d7,_0x739b('0x11'));logger[_0x739b('0x12')](_0x739b('0x13'),_0x48a4d7,_0x739b('0x11'),JSON[_0x739b('0x14')](_0x494b2c));if(_0x494b2c[_0x739b('0x15')]){if(_0x494b2c[_0x739b('0x15')]['code']===0x1f4){logger[_0x739b('0x15')](_0x739b('0x16'),_0x48a4d7,_0x494b2c['error'][_0x739b('0x17')]);return _0x60033a(_0x494b2c[_0x739b('0x15')][_0x739b('0x17')]);}logger[_0x739b('0x15')](_0x739b('0x16'),_0x48a4d7,_0x494b2c[_0x739b('0x15')][_0x739b('0x17')]);return _0x387d95(_0x494b2c[_0x739b('0x15')][_0x739b('0x17')]);}else{logger[_0x739b('0x10')](_0x739b('0x16'),_0x48a4d7,'request\x20sent');_0x387d95(_0x494b2c[_0x739b('0x18')][_0x739b('0x17')]);}})[_0x739b('0x19')](function(_0x57890b){logger[_0x739b('0x15')](_0x739b('0x16'),_0x48a4d7,_0x57890b);_0x60033a(_0x57890b);});});}exports[_0x739b('0x1a')]=function(_0x34a56b){var _0x40590f=this;return new Promise(function(_0x5e9c0d,_0x6014f6){return db[_0x739b('0x1b')][_0x739b('0x1c')]({'raw':_0x34a56b[_0x739b('0x1d')]?_0x34a56b[_0x739b('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x34a56b[_0x739b('0x1d')]?_0x34a56b[_0x739b('0x1d')]['where']||null:null,'attributes':[[db['sequelize']['fn'](_0x739b('0x1e'),db[_0x739b('0x1f')]['fn']('IF',db[_0x739b('0x1f')][_0x739b('0x20')](_0x739b('0x21')))),'outboundQueuePauses']]})[_0x739b('0xf')](function(_0x502160){logger[_0x739b('0x10')](_0x739b('0x1a'),_0x34a56b);logger[_0x739b('0x12')](_0x739b('0x1a'),_0x34a56b,JSON[_0x739b('0x14')](_0x502160));_0x5e9c0d(_0x502160);})[_0x739b('0x19')](function(_0x279958){logger[_0x739b('0x15')](_0x739b('0x1a'),_0x279958['message'],_0x34a56b);_0x6014f6(_0x40590f[_0x739b('0x15')](0x1f4,_0x279958[_0x739b('0x17')]));});});};