2294f505e1c176d90cf002bb868ba2834f893753
[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 _0xd21f=['Dashboard,\x20%s,\x20%s,\x20%s','error','Dashboard,\x20%s,\x20%s','message','catch','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','http','redis','defaults','socket.io-emitter','./dashboard.socket','register','request','then','info','request\x20sent'];(function(_0x4c555,_0x3be8b1){var _0x555a01=function(_0x12b615){while(--_0x12b615){_0x4c555['push'](_0x4c555['shift']());}};_0x555a01(++_0x3be8b1);}(_0xd21f,0xf7));var _0xfd21=function(_0x157d23,_0x4027b9){_0x157d23=_0x157d23-0x0;var _0x5b93cc=_0xd21f[_0x157d23];return _0x5b93cc;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xfd21('0x0'));var BPromise=require(_0xfd21('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xfd21('0x2'));var db=require(_0xfd21('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0xfd21('0x4'))(_0xfd21('0x5'));var config=require(_0xfd21('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0xfd21('0x7')]({'port':0x232a});config[_0xfd21('0x8')]=_[_0xfd21('0x9')](config[_0xfd21('0x8')],{'host':'localhost','port':0x18eb});var socket=require(_0xfd21('0xa'))(new Redis(config[_0xfd21('0x8')]));require(_0xfd21('0xb'))[_0xfd21('0xc')](socket);function respondWithRpcPromise(_0x18f276,_0x588524,_0x2d3f09){return new BPromise(function(_0x21a6a8,_0x1ca4aa){return client[_0xfd21('0xd')](_0x18f276,_0x2d3f09)[_0xfd21('0xe')](function(_0x854f54){logger[_0xfd21('0xf')]('Dashboard,\x20%s,\x20%s',_0x588524,_0xfd21('0x10'));logger['debug'](_0xfd21('0x11'),_0x588524,'request\x20sent',JSON['stringify'](_0x854f54));if(_0x854f54['error']){if(_0x854f54['error']['code']===0x1f4){logger[_0xfd21('0x12')](_0xfd21('0x13'),_0x588524,_0x854f54['error'][_0xfd21('0x14')]);return _0x1ca4aa(_0x854f54['error'][_0xfd21('0x14')]);}logger['error'](_0xfd21('0x13'),_0x588524,_0x854f54['error']['message']);return _0x21a6a8(_0x854f54[_0xfd21('0x12')]['message']);}else{logger['info'](_0xfd21('0x13'),_0x588524,_0xfd21('0x10'));_0x21a6a8(_0x854f54['result'][_0xfd21('0x14')]);}})[_0xfd21('0x15')](function(_0x242520){logger[_0xfd21('0x12')](_0xfd21('0x13'),_0x588524,_0x242520);_0x1ca4aa(_0x242520);});});}