mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
fix: filter Like and Announce to only log reactions to our content
After following remote actors, their servers deliver all activities to our inbox — including likes/boosts of other people's posts. Only log Likes and Announces where the objectUrl starts with our publication URL, filtering out unrelated activity.
This commit is contained in:
@@ -161,13 +161,18 @@ export function registerInboxListeners(inboxChain, options) {
|
||||
}
|
||||
})
|
||||
.on(Like, async (ctx, like) => {
|
||||
const objectId = (await like.getObject())?.id?.href || "";
|
||||
|
||||
// Only log likes of our own content
|
||||
const pubUrl = collections._publicationUrl;
|
||||
if (!objectId || (pubUrl && !objectId.startsWith(pubUrl))) return;
|
||||
|
||||
const actorObj = await like.getActor();
|
||||
const actorUrl = actorObj?.id?.href || "";
|
||||
const actorName =
|
||||
actorObj?.name?.toString() ||
|
||||
actorObj?.preferredUsername?.toString() ||
|
||||
actorUrl;
|
||||
const objectId = (await like.getObject())?.id?.href || "";
|
||||
|
||||
await logActivity(collections, storeRawActivities, {
|
||||
direction: "inbound",
|
||||
@@ -179,13 +184,18 @@ export function registerInboxListeners(inboxChain, options) {
|
||||
});
|
||||
})
|
||||
.on(Announce, async (ctx, announce) => {
|
||||
const objectId = (await announce.getObject())?.id?.href || "";
|
||||
|
||||
// Only log boosts of our own content
|
||||
const pubUrl = collections._publicationUrl;
|
||||
if (!objectId || (pubUrl && !objectId.startsWith(pubUrl))) return;
|
||||
|
||||
const actorObj = await announce.getActor();
|
||||
const actorUrl = actorObj?.id?.href || "";
|
||||
const actorName =
|
||||
actorObj?.name?.toString() ||
|
||||
actorObj?.preferredUsername?.toString() ||
|
||||
actorUrl;
|
||||
const objectId = (await announce.getObject())?.id?.href || "";
|
||||
|
||||
await logActivity(collections, storeRawActivities, {
|
||||
direction: "inbound",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rmdes/indiekit-endpoint-activitypub",
|
||||
"version": "1.0.13",
|
||||
"version": "1.0.14",
|
||||
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
||||
"keywords": [
|
||||
"indiekit",
|
||||
|
||||
Reference in New Issue
Block a user