forked from snxraven/p2ns
improvent for invites
This commit is contained in:
@@ -8,6 +8,7 @@ const { trackRequest, trackRequestWithTiming } = require('../../../maintenance/m
|
||||
const { createErrorResponse } = require('../../../infrastructure/error_handler');
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
const { state } = require('../../../infrastructure/state');
|
||||
|
||||
async function handleDiagnosticsRoutes(req, res) {
|
||||
const urlPath = req.urlPath || new URL(req.url, `https://${req.headers.host}`).pathname;
|
||||
@@ -502,6 +503,30 @@ async function handleDiagnosticsRoutes(req, res) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// GET /api/diagnostics/invites
|
||||
if (method === 'GET' && urlPath === '/api/diagnostics/invites') {
|
||||
try {
|
||||
if (!state.diagnoseInviteIssues) {
|
||||
res.writeHead(503, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ error: 'Invite diagnostics not available - system not fully initialized' }));
|
||||
trackRequest(urlPath, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
const diagnostics = state.diagnoseInviteIssues();
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify(diagnostics));
|
||||
trackRequest(urlPath, true);
|
||||
return true;
|
||||
} catch (err) {
|
||||
logError('DiagnosticsRoute', `Invite diagnostics error: ${err.message}`);
|
||||
res.writeHead(500, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ error: err.message }));
|
||||
trackRequest(urlPath, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user