Built motion from commit ddca4d0d.|2.5.47
[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 _0xa9f1=['GetVoiceQueueRtPauses','findAll','options','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','defaults','redis','localhost','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch'];(function(_0x4bb18d,_0x194efd){var _0x33312e=function(_0x7048fc){while(--_0x7048fc){_0x4bb18d['push'](_0x4bb18d['shift']());}};_0x33312e(++_0x194efd);}(_0xa9f1,0x15c));var _0x1a9f=function(_0x49d706,_0x47d8d7){_0x49d706=_0x49d706-0x0;var _0x47c5ff=_0xa9f1[_0x49d706];return _0x47c5ff;};'use strict';var _=require('lodash');var util=require(_0x1a9f('0x0'));var moment=require(_0x1a9f('0x1'));var BPromise=require(_0x1a9f('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1a9f('0x3'));var db=require(_0x1a9f('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x1a9f('0x5'))(_0x1a9f('0x6'));var config=require(_0x1a9f('0x7'));var jayson=require(_0x1a9f('0x8'));var client=jayson['client'][_0x1a9f('0x9')]({'port':0x232a});config['redis']=_[_0x1a9f('0xa')](config[_0x1a9f('0xb')],{'host':_0x1a9f('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x1a9f('0xb')]));require('./userVoiceQueueRt.socket')[_0x1a9f('0xd')](socket);function respondWithRpcPromise(_0x336fdd,_0x4840a2,_0xe9ef4){return new BPromise(function(_0x5981df,_0x1f8c34){return client[_0x1a9f('0xe')](_0x336fdd,_0xe9ef4)[_0x1a9f('0xf')](function(_0x16fa67){logger[_0x1a9f('0x10')](_0x1a9f('0x11'),_0x4840a2,_0x1a9f('0x12'));logger[_0x1a9f('0x13')]('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x4840a2,_0x1a9f('0x12'),JSON[_0x1a9f('0x14')](_0x16fa67));if(_0x16fa67[_0x1a9f('0x15')]){if(_0x16fa67[_0x1a9f('0x15')][_0x1a9f('0x16')]===0x1f4){logger[_0x1a9f('0x15')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x4840a2,_0x16fa67[_0x1a9f('0x15')][_0x1a9f('0x17')]);return _0x1f8c34(_0x16fa67['error'][_0x1a9f('0x17')]);}logger[_0x1a9f('0x15')](_0x1a9f('0x11'),_0x4840a2,_0x16fa67[_0x1a9f('0x15')][_0x1a9f('0x17')]);return _0x5981df(_0x16fa67['error'][_0x1a9f('0x17')]);}else{logger[_0x1a9f('0x10')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x4840a2,_0x1a9f('0x12'));_0x5981df(_0x16fa67[_0x1a9f('0x18')]['message']);}})[_0x1a9f('0x19')](function(_0x2d115d){logger[_0x1a9f('0x15')](_0x1a9f('0x11'),_0x4840a2,_0x2d115d);_0x1f8c34(_0x2d115d);});});}exports[_0x1a9f('0x1a')]=function(_0x4fd230){var _0x518136=this;return new Promise(function(_0xbde8bd,_0x190e4a){return db['UserVoiceQueueRt'][_0x1a9f('0x1b')]({'raw':_0x4fd230[_0x1a9f('0x1c')]?_0x4fd230[_0x1a9f('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x4fd230[_0x1a9f('0x1c')]?_0x4fd230['options'][_0x1a9f('0x1d')]||null:null,'attributes':[[db[_0x1a9f('0x1e')]['fn'](_0x1a9f('0x1f'),db[_0x1a9f('0x1e')]['fn']('IF',db['sequelize'][_0x1a9f('0x20')](_0x1a9f('0x21')))),'outboundQueuePauses']]})[_0x1a9f('0xf')](function(_0x2a4ee5){logger['info']('GetVoiceQueueRtPauses',_0x4fd230);logger[_0x1a9f('0x13')](_0x1a9f('0x1a'),_0x4fd230,JSON[_0x1a9f('0x14')](_0x2a4ee5));_0xbde8bd(_0x2a4ee5);})[_0x1a9f('0x19')](function(_0x3ed309){logger[_0x1a9f('0x15')](_0x1a9f('0x1a'),_0x3ed309['message'],_0x4fd230);_0x190e4a(_0x518136[_0x1a9f('0x15')](0x1f4,_0x3ed309[_0x1a9f('0x17')]));});});};