Built motion from commit f0b1811d.|2.6.6
[motion2.git] / server / api / dashboard / dashboard.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 _0xa0e8=['client','defaults','localhost','socket.io-emitter','register','request','then','info','Dashboard,\x20%s,\x20%s','request\x20sent','Dashboard,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','moment','bluebird','ioredis','../../mysqldb','../../config/logger','jayson/promise'];(function(_0x479773,_0x4a1ff1){var _0x5c4f1c=function(_0x6d7741){while(--_0x6d7741){_0x479773['push'](_0x479773['shift']());}};_0x5c4f1c(++_0x4a1ff1);}(_0xa0e8,0x102));var _0x8a0e=function(_0x2e9842,_0x514356){_0x2e9842=_0x2e9842-0x0;var _0x44e929=_0xa0e8[_0x2e9842];return _0x44e929;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x8a0e('0x0'));var BPromise=require(_0x8a0e('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x8a0e('0x2'));var db=require(_0x8a0e('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x8a0e('0x4'))('rpc');var config=require('../../config/environment');var jayson=require(_0x8a0e('0x5'));var client=jayson[_0x8a0e('0x6')]['http']({'port':0x232a});config['redis']=_[_0x8a0e('0x7')](config['redis'],{'host':_0x8a0e('0x8'),'port':0x18eb});var socket=require(_0x8a0e('0x9'))(new Redis(config['redis']));require('./dashboard.socket')[_0x8a0e('0xa')](socket);function respondWithRpcPromise(_0x267981,_0x117421,_0x564a76){return new BPromise(function(_0xd285ff,_0x267973){return client[_0x8a0e('0xb')](_0x267981,_0x564a76)[_0x8a0e('0xc')](function(_0x6245df){logger[_0x8a0e('0xd')](_0x8a0e('0xe'),_0x117421,_0x8a0e('0xf'));logger['debug'](_0x8a0e('0x10'),_0x117421,_0x8a0e('0xf'),JSON[_0x8a0e('0x11')](_0x6245df));if(_0x6245df[_0x8a0e('0x12')]){if(_0x6245df['error'][_0x8a0e('0x13')]===0x1f4){logger['error']('Dashboard,\x20%s,\x20%s',_0x117421,_0x6245df[_0x8a0e('0x12')][_0x8a0e('0x14')]);return _0x267973(_0x6245df[_0x8a0e('0x12')][_0x8a0e('0x14')]);}logger['error'](_0x8a0e('0xe'),_0x117421,_0x6245df[_0x8a0e('0x12')]['message']);return _0xd285ff(_0x6245df[_0x8a0e('0x12')]['message']);}else{logger['info'](_0x8a0e('0xe'),_0x117421,'request\x20sent');_0xd285ff(_0x6245df['result']['message']);}})[_0x8a0e('0x15')](function(_0x17b03d){logger[_0x8a0e('0x12')](_0x8a0e('0xe'),_0x117421,_0x17b03d);_0x267973(_0x17b03d);});});}