mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-04 10:29:44 +02:00
feat: record AP parsing failures, save activity in db for 24h
This commit is contained in:
@@ -481,6 +481,18 @@ ActivityPub.record.send = async ({ type, target }) => {
|
||||
]);
|
||||
};
|
||||
|
||||
ActivityPub.record.receiptError = async (body) => {
|
||||
const { id, actor } = body;
|
||||
const now = Date.now();
|
||||
const { hostname } = new URL(actor);
|
||||
await Promise.all([
|
||||
db.sortedSetAdd('ap.errors', now, id),
|
||||
db.set(`ap.errors:${id}`, JSON.stringify(body)),
|
||||
analytics.increment(['ap.inErr', `ap.inErr:byHost:${hostname}`]),
|
||||
]);
|
||||
await db.expire(`ap.errors:${id}`, 60 * 60 * 24); // 24 hours
|
||||
};
|
||||
|
||||
ActivityPub.buildRecipients = async function (object, options) {
|
||||
/**
|
||||
* - Builds a list of targets for activitypub.send to consume
|
||||
|
||||
@@ -272,6 +272,7 @@ Controller.postInbox = async (req, res) => {
|
||||
await activitypub.record.receipt(req.body);
|
||||
await helpers.formatApiResponse(202, res);
|
||||
} catch (e) {
|
||||
activitypub.record.receiptError(req.body);
|
||||
helpers.formatApiResponse(500, res, e).catch(err => winston.error(err.stack));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<div id="spy-container" class="col-12 col-md-8 px-0 mb-4" tabindex="0">
|
||||
<div class="mb-4">
|
||||
<p class="lead">[[admin/settings/activitypub:analytics.intro]]</p>
|
||||
<p>[[admin/settings/activitypub:analytics.details]]</p>
|
||||
|
||||
<div class="mb-3 row">
|
||||
<div class="col-6">
|
||||
|
||||
Reference in New Issue
Block a user