dfb1c7c545a9135e750da5897254bb073e6d774c
[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 _0x2a87=['stringify','error','message','result','catch','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','redis','defaults','./dashboard.socket','request','then','Dashboard,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x3d169b,_0x3a3b27){var _0x29f8ca=function(_0x5d82c8){while(--_0x5d82c8){_0x3d169b['push'](_0x3d169b['shift']());}};_0x29f8ca(++_0x3a3b27);}(_0x2a87,0x175));var _0x72a8=function(_0x1eec3a,_0x168828){_0x1eec3a=_0x1eec3a-0x0;var _0x133cf7=_0x2a87[_0x1eec3a];return _0x133cf7;};'use strict';var _=require('lodash');var util=require(_0x72a8('0x0'));var moment=require(_0x72a8('0x1'));var BPromise=require('bluebird');var rs=require(_0x72a8('0x2'));var fs=require('fs');var Redis=require(_0x72a8('0x3'));var db=require(_0x72a8('0x4'))['db'];var utils=require(_0x72a8('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x72a8('0x6'));var jayson=require(_0x72a8('0x7'));var client=jayson[_0x72a8('0x8')][_0x72a8('0x9')]({'port':0x232a});config[_0x72a8('0xa')]=_[_0x72a8('0xb')](config[_0x72a8('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x72a8('0xa')]));require(_0x72a8('0xc'))['register'](socket);function respondWithRpcPromise(_0x5b08cb,_0x256c1e,_0x3e624f){return new BPromise(function(_0x387e6d,_0x2bc2f6){return client[_0x72a8('0xd')](_0x5b08cb,_0x3e624f)[_0x72a8('0xe')](function(_0x41ad82){logger['info'](_0x72a8('0xf'),_0x256c1e,_0x72a8('0x10'));logger[_0x72a8('0x11')]('Dashboard,\x20%s,\x20%s,\x20%s',_0x256c1e,'request\x20sent',JSON[_0x72a8('0x12')](_0x41ad82));if(_0x41ad82[_0x72a8('0x13')]){if(_0x41ad82[_0x72a8('0x13')]['code']===0x1f4){logger['error']('Dashboard,\x20%s,\x20%s',_0x256c1e,_0x41ad82[_0x72a8('0x13')]['message']);return _0x2bc2f6(_0x41ad82[_0x72a8('0x13')][_0x72a8('0x14')]);}logger[_0x72a8('0x13')](_0x72a8('0xf'),_0x256c1e,_0x41ad82[_0x72a8('0x13')]['message']);return _0x387e6d(_0x41ad82[_0x72a8('0x13')][_0x72a8('0x14')]);}else{logger['info']('Dashboard,\x20%s,\x20%s',_0x256c1e,'request\x20sent');_0x387e6d(_0x41ad82[_0x72a8('0x15')][_0x72a8('0x14')]);}})[_0x72a8('0x16')](function(_0x4e745e){logger[_0x72a8('0x13')](_0x72a8('0xf'),_0x256c1e,_0x4e745e);_0x2bc2f6(_0x4e745e);});});}