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:
+12
-2
@@ -161,13 +161,18 @@ export function registerInboxListeners(inboxChain, options) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on(Like, async (ctx, like) => {
|
.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 actorObj = await like.getActor();
|
||||||
const actorUrl = actorObj?.id?.href || "";
|
const actorUrl = actorObj?.id?.href || "";
|
||||||
const actorName =
|
const actorName =
|
||||||
actorObj?.name?.toString() ||
|
actorObj?.name?.toString() ||
|
||||||
actorObj?.preferredUsername?.toString() ||
|
actorObj?.preferredUsername?.toString() ||
|
||||||
actorUrl;
|
actorUrl;
|
||||||
const objectId = (await like.getObject())?.id?.href || "";
|
|
||||||
|
|
||||||
await logActivity(collections, storeRawActivities, {
|
await logActivity(collections, storeRawActivities, {
|
||||||
direction: "inbound",
|
direction: "inbound",
|
||||||
@@ -179,13 +184,18 @@ export function registerInboxListeners(inboxChain, options) {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.on(Announce, async (ctx, announce) => {
|
.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 actorObj = await announce.getActor();
|
||||||
const actorUrl = actorObj?.id?.href || "";
|
const actorUrl = actorObj?.id?.href || "";
|
||||||
const actorName =
|
const actorName =
|
||||||
actorObj?.name?.toString() ||
|
actorObj?.name?.toString() ||
|
||||||
actorObj?.preferredUsername?.toString() ||
|
actorObj?.preferredUsername?.toString() ||
|
||||||
actorUrl;
|
actorUrl;
|
||||||
const objectId = (await announce.getObject())?.id?.href || "";
|
|
||||||
|
|
||||||
await logActivity(collections, storeRawActivities, {
|
await logActivity(collections, storeRawActivities, {
|
||||||
direction: "inbound",
|
direction: "inbound",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rmdes/indiekit-endpoint-activitypub",
|
"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.",
|
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"indiekit",
|
"indiekit",
|
||||||
|
|||||||
Reference in New Issue
Block a user