Skip to content

Node.js based forum software built for the modern web

feat: timestamp in ap errors page

Julian Lam55ce9c07e4ef
diff --git a/src/controllers/admin/federation.js b/src/controllers/admin/federation.js
index 95cfedc5e5..d94dd0726c 100644
--- a/src/controllers/admin/federation.js
+++ b/src/controllers/admin/federation.js
@@ -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', {
diff --git a/src/views/admin/federation/errors.tpl b/src/views/admin/federation/errors.tpl
index 174d58dcc7..8af5c18945 100644
--- a/src/views/admin/federation/errors.tpl
+++ b/src/views/admin/federation/errors.tpl
@@ -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>