mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 00:17:15 +02:00
feat: timestamp in ap errors page
This commit is contained in:
@@ -87,11 +87,12 @@ federationController.analytics = async function (req, res) {
|
||||
};
|
||||
|
||||
federationController.errors = async function (req, res) {
|
||||
const ids = await db.getSortedSetRevRangeByScore('ap.errors', 0, -1, Date.now(), '-inf');
|
||||
const errorObj = await db.getObjects(ids.map(id => `ap.errors:${id}`));
|
||||
const errors = ids.map((id, idx) => {
|
||||
let errors = await db.getSortedSetRevRangeByScoreWithScores('ap.errors', 0, -1, Date.now(), '-inf');
|
||||
const errorObj = await db.getObjects(errors.map(({ value: id }) => `ap.errors:${id}`));
|
||||
errors = errors.map(({ value: id, score: timestamp }, idx) => {
|
||||
let { body, stack } = errorObj[idx];
|
||||
let hostname = 'Invalid hostname';
|
||||
const timestampISO = new Date(timestamp).toISOString();
|
||||
try {
|
||||
body = JSON.stringify(JSON.parse(body), null, 4);
|
||||
({ hostname } = new URL(id));
|
||||
@@ -99,7 +100,7 @@ federationController.errors = async function (req, res) {
|
||||
// noop
|
||||
}
|
||||
|
||||
return { id, body, stack, hostname };
|
||||
return { id, body, stack, hostname, timestamp, timestampISO };
|
||||
});
|
||||
|
||||
res.render('admin/federation/errors', {
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
<div class="col-12 col-md-4" id="errors">
|
||||
{{{ each errors }}}
|
||||
<details class="mb-3" data-index="{@index}">
|
||||
<summary>{./id}</summary>
|
||||
<summary>
|
||||
<span title="{./timestampISO}" class="timeago text-secondary text-sm"></span><br/ >
|
||||
<code>{./id}</code>
|
||||
</summary>
|
||||
|
||||
{{{ if ./stack }}}
|
||||
<pre class="m-2 border p-2"><code>{./stack}</code></pre>
|
||||
|
||||
Reference in New Issue
Block a user