Built motion from commit 97153652.|2.6.26
[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 _0x9f67=['catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','then','lodash','util','moment','bluebird','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./userVoiceQueueRt.socket','request','request\x20sent','debug','stringify','error','code','message','UserVoiceQueueRt,\x20%s,\x20%s','info'];(function(_0x2261b3,_0x17fc2){var _0x58f9cf=function(_0x1d62bc){while(--_0x1d62bc){_0x2261b3['push'](_0x2261b3['shift']());}};_0x58f9cf(++_0x17fc2);}(_0x9f67,0x1e0));var _0x79f6=function(_0x1c82f6,_0x2b4668){_0x1c82f6=_0x1c82f6-0x0;var _0x42594c=_0x9f67[_0x1c82f6];return _0x42594c;};'use strict';var _=require(_0x79f6('0x0'));var util=require(_0x79f6('0x1'));var moment=require(_0x79f6('0x2'));var BPromise=require(_0x79f6('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x79f6('0x4'));var db=require(_0x79f6('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x79f6('0x6'));var config=require(_0x79f6('0x7'));var jayson=require(_0x79f6('0x8'));var client=jayson[_0x79f6('0x9')][_0x79f6('0xa')]({'port':0x232a});config[_0x79f6('0xb')]=_[_0x79f6('0xc')](config[_0x79f6('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0x79f6('0xd'))(new Redis(config['redis']));require(_0x79f6('0xe'))['register'](socket);function respondWithRpcPromise(_0x41b321,_0x54649e,_0x4134e4){return new BPromise(function(_0x631f05,_0xae5e37){return client[_0x79f6('0xf')](_0x41b321,_0x4134e4)['then'](function(_0x4e761b){logger['info']('UserVoiceQueueRt,\x20%s,\x20%s',_0x54649e,_0x79f6('0x10'));logger[_0x79f6('0x11')]('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x54649e,_0x79f6('0x10'),JSON[_0x79f6('0x12')](_0x4e761b));if(_0x4e761b[_0x79f6('0x13')]){if(_0x4e761b[_0x79f6('0x13')][_0x79f6('0x14')]===0x1f4){logger[_0x79f6('0x13')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x54649e,_0x4e761b[_0x79f6('0x13')]['message']);return _0xae5e37(_0x4e761b[_0x79f6('0x13')][_0x79f6('0x15')]);}logger[_0x79f6('0x13')](_0x79f6('0x16'),_0x54649e,_0x4e761b[_0x79f6('0x13')][_0x79f6('0x15')]);return _0x631f05(_0x4e761b[_0x79f6('0x13')][_0x79f6('0x15')]);}else{logger[_0x79f6('0x17')](_0x79f6('0x16'),_0x54649e,_0x79f6('0x10'));_0x631f05(_0x4e761b['result'][_0x79f6('0x15')]);}})[_0x79f6('0x18')](function(_0x55e6c7){logger[_0x79f6('0x13')](_0x79f6('0x16'),_0x54649e,_0x55e6c7);_0xae5e37(_0x55e6c7);});});}exports[_0x79f6('0x19')]=function(_0x5ee2e8){var _0x491bb9=this;return new Promise(function(_0x1488b0,_0x2436b7){return db[_0x79f6('0x1a')][_0x79f6('0x1b')]({'raw':_0x5ee2e8[_0x79f6('0x1c')]?_0x5ee2e8['options']['raw']===undefined?!![]:![]:!![],'where':_0x5ee2e8[_0x79f6('0x1c')]?_0x5ee2e8[_0x79f6('0x1c')][_0x79f6('0x1d')]||null:null,'attributes':[[db[_0x79f6('0x1e')]['fn'](_0x79f6('0x1f'),db[_0x79f6('0x1e')]['fn']('IF',db[_0x79f6('0x1e')][_0x79f6('0x20')](_0x79f6('0x21')))),_0x79f6('0x22')]]})[_0x79f6('0x23')](function(_0x6b5f92){logger[_0x79f6('0x17')](_0x79f6('0x19'),_0x5ee2e8);logger[_0x79f6('0x11')](_0x79f6('0x19'),_0x5ee2e8,JSON[_0x79f6('0x12')](_0x6b5f92));_0x1488b0(_0x6b5f92);})[_0x79f6('0x18')](function(_0x5b4812){logger[_0x79f6('0x13')]('GetVoiceQueueRtPauses',_0x5b4812['message'],_0x5ee2e8);_0x2436b7(_0x491bb9['error'](0x1f4,_0x5b4812[_0x79f6('0x15')]));});});};