68ae4964c5935636677704c4447728313a99b2d7
[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 _0x80b9=['http','redis','defaults','localhost','socket.io-emitter','./dashboard.socket','register','info','Dashboard,\x20%s,\x20%s','request\x20sent','Dashboard,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client'];(function(_0x2bda14,_0x4fab1b){var _0xb5dd49=function(_0x1da71e){while(--_0x1da71e){_0x2bda14['push'](_0x2bda14['shift']());}};_0xb5dd49(++_0x4fab1b);}(_0x80b9,0x123));var _0x980b=function(_0x6d21a2,_0x27e591){_0x6d21a2=_0x6d21a2-0x0;var _0x32d1b0=_0x80b9[_0x6d21a2];return _0x32d1b0;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x980b('0x0'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x980b('0x1'));var db=require(_0x980b('0x2'))['db'];var utils=require(_0x980b('0x3'));var logger=require(_0x980b('0x4'))(_0x980b('0x5'));var config=require(_0x980b('0x6'));var jayson=require(_0x980b('0x7'));var client=jayson[_0x980b('0x8')][_0x980b('0x9')]({'port':0x232a});config[_0x980b('0xa')]=_[_0x980b('0xb')](config[_0x980b('0xa')],{'host':_0x980b('0xc'),'port':0x18eb});var socket=require(_0x980b('0xd'))(new Redis(config[_0x980b('0xa')]));require(_0x980b('0xe'))[_0x980b('0xf')](socket);function respondWithRpcPromise(_0x456a4e,_0x525331,_0x1e403e){return new BPromise(function(_0x31c497,_0x4931f5){return client['request'](_0x456a4e,_0x1e403e)['then'](function(_0x2e11b8){logger[_0x980b('0x10')](_0x980b('0x11'),_0x525331,_0x980b('0x12'));logger['debug'](_0x980b('0x13'),_0x525331,_0x980b('0x12'),JSON[_0x980b('0x14')](_0x2e11b8));if(_0x2e11b8['error']){if(_0x2e11b8[_0x980b('0x15')]['code']===0x1f4){logger['error'](_0x980b('0x11'),_0x525331,_0x2e11b8['error'][_0x980b('0x16')]);return _0x4931f5(_0x2e11b8[_0x980b('0x15')][_0x980b('0x16')]);}logger[_0x980b('0x15')](_0x980b('0x11'),_0x525331,_0x2e11b8[_0x980b('0x15')][_0x980b('0x16')]);return _0x31c497(_0x2e11b8[_0x980b('0x15')][_0x980b('0x16')]);}else{logger['info']('Dashboard,\x20%s,\x20%s',_0x525331,'request\x20sent');_0x31c497(_0x2e11b8[_0x980b('0x17')]['message']);}})[_0x980b('0x18')](function(_0x370d2a){logger[_0x980b('0x15')](_0x980b('0x11'),_0x525331,_0x370d2a);_0x4931f5(_0x370d2a);});});}