Skip to content

Commit

Permalink
fix: prevent automatic ingestion of all notes for non-followed actors
Browse files Browse the repository at this point in the history
  • Loading branch information
akhileshthite committed May 27, 2024
1 parent 21e6e8d commit f8e593a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit f8e593a

Please sign in to comment.