768d01072eff78e0fd1d7f2cb465af05c40579f8
[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 _0x5be5=['message','Dashboard,\x20%s,\x20%s','result','catch','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','socket.io-emitter','./dashboard.socket','register','request','info','request\x20sent','Dashboard,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x13ce0c,_0x3f2a0d){var _0x4388fb=function(_0x27db4b){while(--_0x27db4b){_0x13ce0c['push'](_0x13ce0c['shift']());}};_0x4388fb(++_0x3f2a0d);}(_0x5be5,0x100));var _0x55be=function(_0x8f448c,_0x5587a4){_0x8f448c=_0x8f448c-0x0;var _0x24b4e3=_0x5be5[_0x8f448c];return _0x24b4e3;};'use strict';var _=require(_0x55be('0x0'));var util=require(_0x55be('0x1'));var moment=require(_0x55be('0x2'));var BPromise=require(_0x55be('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x55be('0x4'));var db=require(_0x55be('0x5'))['db'];var utils=require(_0x55be('0x6'));var logger=require(_0x55be('0x7'))(_0x55be('0x8'));var config=require(_0x55be('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x55be('0xa')][_0x55be('0xb')]({'port':0x232a});config[_0x55be('0xc')]=_[_0x55be('0xd')](config[_0x55be('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x55be('0xe'))(new Redis(config[_0x55be('0xc')]));require(_0x55be('0xf'))[_0x55be('0x10')](socket);function respondWithRpcPromise(_0x460777,_0x1b33f2,_0x45bff5){return new BPromise(function(_0x8d9970,_0x55ce76){return client[_0x55be('0x11')](_0x460777,_0x45bff5)['then'](function(_0x139125){logger[_0x55be('0x12')]('Dashboard,\x20%s,\x20%s',_0x1b33f2,_0x55be('0x13'));logger['debug'](_0x55be('0x14'),_0x1b33f2,_0x55be('0x13'),JSON[_0x55be('0x15')](_0x139125));if(_0x139125[_0x55be('0x16')]){if(_0x139125['error'][_0x55be('0x17')]===0x1f4){logger[_0x55be('0x16')]('Dashboard,\x20%s,\x20%s',_0x1b33f2,_0x139125[_0x55be('0x16')][_0x55be('0x18')]);return _0x55ce76(_0x139125[_0x55be('0x16')]['message']);}logger[_0x55be('0x16')](_0x55be('0x19'),_0x1b33f2,_0x139125[_0x55be('0x16')]['message']);return _0x8d9970(_0x139125['error']['message']);}else{logger[_0x55be('0x12')](_0x55be('0x19'),_0x1b33f2,_0x55be('0x13'));_0x8d9970(_0x139125[_0x55be('0x1a')]['message']);}})[_0x55be('0x1b')](function(_0x12ccc6){logger['error'](_0x55be('0x19'),_0x1b33f2,_0x12ccc6);_0x55ce76(_0x12ccc6);});});}