From f8e593a1cde3a4aab575be1a131e6f64394e1ae8 Mon Sep 17 00:00:00 2001 From: Akhilesh Thite Date: Mon, 27 May 2024 19:59:13 +0530 Subject: [PATCH] fix: prevent automatic ingestion of all notes for non-followed actors --- db.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/db.js b/db.js index f09b0c6..4760e8a 100644 --- a/db.js +++ b/db.js @@ -360,7 +360,7 @@ export class ActivityPubDB extends EventTarget { const note = await this.#get(activity.object) if (note.type === TYPE_NOTE) { console.log('Ingesting note:', note) - await this.ingestNote(note) + await this.ingestNote(note, true) } } else if (activity.type === TYPE_DELETE) { // Handle 'Delete' activity type @@ -370,7 +370,13 @@ export class ActivityPubDB extends EventTarget { return true } - async ingestNote (note) { + async ingestNote (note, forceIngest = false) { + const isFollowed = await this.isActorFollowed(note.attributedTo) + if (!isFollowed && !forceIngest) { + console.log('Skipping note ingestion as actor is not followed and forceIngest is false.') + return + } + console.log('Ingesting note', note) // Convert needed fields to date note.published = new Date(note.published)