mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 16:06:08 +02:00
fix: send type in api response, trim whitespace from stacktrace, escape stack trace
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const validator = require('validator');
|
||||
|
||||
const db = require('../../database');
|
||||
const activitypub = require('../../activitypub');
|
||||
const analytics = require('../../analytics');
|
||||
@@ -93,17 +95,18 @@ federationController.errors = async function (req, res) {
|
||||
if (!errorObj[idx]) {
|
||||
return null;
|
||||
}
|
||||
let { body, stack } = errorObj[idx];
|
||||
let { type, body, stack } = errorObj[idx];
|
||||
let hostname = 'Invalid hostname';
|
||||
const timestampISO = new Date(timestamp).toISOString();
|
||||
try {
|
||||
body = JSON.stringify(JSON.parse(body), null, 4);
|
||||
stack = validator.escape(stack.replace(/\s+$/gm, ''));
|
||||
({ hostname } = new URL(id));
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
|
||||
return { id, body, stack, hostname, timestamp, timestampISO };
|
||||
return { id, type, body, stack, hostname, timestamp, timestampISO };
|
||||
}).filter(Boolean);
|
||||
|
||||
res.render('admin/federation/errors', {
|
||||
|
||||
@@ -20,12 +20,6 @@
|
||||
{{{ if ./stack }}}
|
||||
<pre class="m-2 border p-2"><code>{./stack}</code></pre>
|
||||
{{{ end }}}
|
||||
|
||||
{{{ if ./body }}}
|
||||
<!-- <pre class="m-2 border p-2"><code>{./body}</code></pre> -->
|
||||
{{{ else }}}
|
||||
<em>[[admin/settings/activitypub:errors.payload-gone]]</em>
|
||||
{{{ end }}}
|
||||
</details>
|
||||
{{{ end }}}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user