diff --git a/public/language/en-GB/admin/settings/activitypub.json b/public/language/en-GB/admin/settings/activitypub.json index c86caee393..3cb41ede38 100644 --- a/public/language/en-GB/admin/settings/activitypub.json +++ b/public/language/en-GB/admin/settings/activitypub.json @@ -77,6 +77,6 @@ "analytics.hourly": "Hourly", "analytics.daily": "Daily", - "errors.intro": "The following errors were recorded by this instance within the last 24 hours.", + "errors.intro": "The following %1 error(s) were recorded by this instance within the last 24 hours.", "errors.payload-gone": "The payload for this error no longer exists." } \ No newline at end of file diff --git a/public/src/admin/federation/errors.js b/public/src/admin/federation/errors.js new file mode 100644 index 0000000000..edc626d06f --- /dev/null +++ b/public/src/admin/federation/errors.js @@ -0,0 +1,22 @@ +'use strict'; + +export function init() { + const errorsEl = document.getElementById('errors'); + if (errorsEl) { + errorsEl.addEventListener('toggle', handleToggle, true); + } +} + +function handleToggle(e) { + const payloadEl = document.getElementById('payload'); + + if (e.target.open) { + const index = e.target.getAttribute('data-index'); + const error = ajaxify.data.errors[index]; + console.log(error); + + payloadEl.innerText = error.body; + } else { + payloadEl.innerText = ''; + } +} \ No newline at end of file diff --git a/src/controllers/admin/federation.js b/src/controllers/admin/federation.js index 2b67efecd1..29be877ec5 100644 --- a/src/controllers/admin/federation.js +++ b/src/controllers/admin/federation.js @@ -91,13 +91,15 @@ federationController.errors = async function (req, res) { const errorObj = await db.getObjects(ids.map(id => `ap.errors:${id}`)); const errors = ids.map((id, idx) => { let { body, stack } = errorObj[idx]; + let hostname = 'Invalid hostname'; try { body = JSON.stringify(JSON.parse(body), null, 4); + ({ hostname } = new URL(id)); } catch (e) { // noop } - return { id, body, stack }; + return { id, body, stack, hostname }; }); res.render('admin/federation/errors', { diff --git a/src/views/admin/federation/errors.tpl b/src/views/admin/federation/errors.tpl index 6b6afdb51f..174d58dcc7 100644 --- a/src/views/admin/federation/errors.tpl +++ b/src/views/admin/federation/errors.tpl @@ -1,28 +1,30 @@ -
[[admin/settings/activitypub:errors.intro]]
- {{{ each errors }}} -{./stack}
- {{{ end }}}
-
- {{{ if ./body }}}
- {./body}
- {{{ else }}}
- [[admin/settings/activitypub:errors.payload-gone]]
- {{{ end }}}
- [[admin/settings/activitypub:errors.intro, {errors.length}]]
+ +{./stack}
+ {{{ end }}}
+
+ {{{ if ./body }}}
+
+ {{{ else }}}
+ [[admin/settings/activitypub:errors.payload-gone]]
+ {{{ end }}}
+