Built motion from commit 5b761a7b.|2.5.36
[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 _0x799a=['localhost','socket.io-emitter','./userVoiceQueueRt.socket','request','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','options','raw','where','sequelize','outboundQueuePauses','then','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','redis'];(function(_0x4ce3d8,_0x4a3a51){var _0x3d4571=function(_0x29391f){while(--_0x29391f){_0x4ce3d8['push'](_0x4ce3d8['shift']());}};_0x3d4571(++_0x4a3a51);}(_0x799a,0x16a));var _0xa799=function(_0x46ac3b,_0x21f3ad){_0x46ac3b=_0x46ac3b-0x0;var _0x40116f=_0x799a[_0x46ac3b];return _0x40116f;};'use strict';var _=require(_0xa799('0x0'));var util=require('util');var moment=require(_0xa799('0x1'));var BPromise=require(_0xa799('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa799('0x3'));var db=require(_0xa799('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xa799('0x5'))(_0xa799('0x6'));var config=require(_0xa799('0x7'));var jayson=require(_0xa799('0x8'));var client=jayson['client']['http']({'port':0x232a});config[_0xa799('0x9')]=_['defaults'](config[_0xa799('0x9')],{'host':_0xa799('0xa'),'port':0x18eb});var socket=require(_0xa799('0xb'))(new Redis(config['redis']));require(_0xa799('0xc'))['register'](socket);function respondWithRpcPromise(_0x2e0f30,_0x2c3cad,_0x1b125e){return new BPromise(function(_0x5aa7d8,_0x50c98d){return client[_0xa799('0xd')](_0x2e0f30,_0x1b125e)['then'](function(_0x28b8fd){logger[_0xa799('0xe')](_0xa799('0xf'),_0x2c3cad,_0xa799('0x10'));logger[_0xa799('0x11')]('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x2c3cad,'request\x20sent',JSON[_0xa799('0x12')](_0x28b8fd));if(_0x28b8fd[_0xa799('0x13')]){if(_0x28b8fd['error'][_0xa799('0x14')]===0x1f4){logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x2c3cad,_0x28b8fd[_0xa799('0x13')][_0xa799('0x15')]);return _0x50c98d(_0x28b8fd['error'][_0xa799('0x15')]);}logger[_0xa799('0x13')](_0xa799('0xf'),_0x2c3cad,_0x28b8fd['error']['message']);return _0x5aa7d8(_0x28b8fd[_0xa799('0x13')][_0xa799('0x15')]);}else{logger[_0xa799('0xe')](_0xa799('0xf'),_0x2c3cad,_0xa799('0x10'));_0x5aa7d8(_0x28b8fd['result'][_0xa799('0x15')]);}})[_0xa799('0x16')](function(_0x38af14){logger[_0xa799('0x13')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x2c3cad,_0x38af14);_0x50c98d(_0x38af14);});});}exports[_0xa799('0x17')]=function(_0x5bff41){var _0x326126=this;return new Promise(function(_0xd85a76,_0x2d1dd0){return db[_0xa799('0x18')]['findAll']({'raw':_0x5bff41['options']?_0x5bff41[_0xa799('0x19')][_0xa799('0x1a')]===undefined?!![]:![]:!![],'where':_0x5bff41[_0xa799('0x19')]?_0x5bff41['options'][_0xa799('0x1b')]||null:null,'attributes':[[db['sequelize']['fn']('COUNT',db[_0xa799('0x1c')]['fn']('IF',db[_0xa799('0x1c')]['literal']('`paused`\x20=\x201,\x201,\x20null'))),_0xa799('0x1d')]]})[_0xa799('0x1e')](function(_0x35e9a1){logger[_0xa799('0xe')](_0xa799('0x17'),_0x5bff41);logger[_0xa799('0x11')](_0xa799('0x17'),_0x5bff41,JSON[_0xa799('0x12')](_0x35e9a1));_0xd85a76(_0x35e9a1);})[_0xa799('0x16')](function(_0x427fef){logger['error'](_0xa799('0x17'),_0x427fef[_0xa799('0x15')],_0x5bff41);_0x2d1dd0(_0x326126['error'](0x1f4,_0x427fef[_0xa799('0x15')]));});});};