3db26373f5889a2bda7369b1e3864bafbee3e154
[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 _0x4c7d=['moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','socket.io-emitter','./dashboard.socket','register','then','Dashboard,\x20%s,\x20%s','request\x20sent','debug','Dashboard,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','lodash','util'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x4c7d,0xdf));var _0xd4c7=function(_0x43b9f8,_0xcfdc0f){_0x43b9f8=_0x43b9f8-0x0;var _0x6c5c6a=_0x4c7d[_0x43b9f8];return _0x6c5c6a;};'use strict';var _=require(_0xd4c7('0x0'));var util=require(_0xd4c7('0x1'));var moment=require(_0xd4c7('0x2'));var BPromise=require('bluebird');var rs=require(_0xd4c7('0x3'));var fs=require('fs');var Redis=require(_0xd4c7('0x4'));var db=require(_0xd4c7('0x5'))['db'];var utils=require(_0xd4c7('0x6'));var logger=require(_0xd4c7('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0xd4c7('0x8'));var client=jayson[_0xd4c7('0x9')][_0xd4c7('0xa')]({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xd4c7('0xb'))(new Redis(config['redis']));require(_0xd4c7('0xc'))[_0xd4c7('0xd')](socket);function respondWithRpcPromise(_0x672f2f,_0x1c299b,_0x45ad3c){return new BPromise(function(_0x1f8d52,_0x5e1db7){return client['request'](_0x672f2f,_0x45ad3c)[_0xd4c7('0xe')](function(_0x815fed){logger['info'](_0xd4c7('0xf'),_0x1c299b,_0xd4c7('0x10'));logger[_0xd4c7('0x11')](_0xd4c7('0x12'),_0x1c299b,'request\x20sent',JSON[_0xd4c7('0x13')](_0x815fed));if(_0x815fed[_0xd4c7('0x14')]){if(_0x815fed[_0xd4c7('0x14')]['code']===0x1f4){logger[_0xd4c7('0x14')]('Dashboard,\x20%s,\x20%s',_0x1c299b,_0x815fed[_0xd4c7('0x14')][_0xd4c7('0x15')]);return _0x5e1db7(_0x815fed[_0xd4c7('0x14')][_0xd4c7('0x15')]);}logger[_0xd4c7('0x14')]('Dashboard,\x20%s,\x20%s',_0x1c299b,_0x815fed[_0xd4c7('0x14')][_0xd4c7('0x15')]);return _0x1f8d52(_0x815fed[_0xd4c7('0x14')][_0xd4c7('0x15')]);}else{logger[_0xd4c7('0x16')]('Dashboard,\x20%s,\x20%s',_0x1c299b,'request\x20sent');_0x1f8d52(_0x815fed[_0xd4c7('0x17')]['message']);}})[_0xd4c7('0x18')](function(_0x581e52){logger[_0xd4c7('0x14')](_0xd4c7('0xf'),_0x1c299b,_0x581e52);_0x5e1db7(_0x581e52);});});}