summaryrefslogtreecommitdiff
path: root/packages/backend/src/queue/processors
diff options
context:
space:
mode:
authorMarie <marie@kaifa.ch>2023-12-31 03:48:51 +0100
committerMarie <marie@kaifa.ch>2023-12-31 03:48:51 +0100
commit667daebb79c09f7ab80f97e5d3dd30f5b5add4a5 (patch)
tree233ab916da17f8194d0c0e92da3d8bf1be4c69b5 /packages/backend/src/queue/processors
parentupd: remove collapsed mentions (diff)
downloadsharkey-667daebb79c09f7ab80f97e5d3dd30f5b5add4a5.tar.gz
sharkey-667daebb79c09f7ab80f97e5d3dd30f5b5add4a5.tar.bz2
sharkey-667daebb79c09f7ab80f97e5d3dd30f5b5add4a5.zip
upd: prevent vanilla mastodon imports from importing DMs
Also adds the visibility function to mastodon imports
Diffstat (limited to 'packages/backend/src/queue/processors')
-rw-r--r--packages/backend/src/queue/processors/ImportNotesProcessorService.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts
index 552b69d92d..942870dfc7 100644
--- a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts
+++ b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts
@@ -72,7 +72,6 @@ export class ImportNotesProcessorService {
}
}
- // Function was taken from Firefish and modified for our needs
@bindThis
private async recreateChain(idFieldPath: string[], replyFieldPath: string[], arr: any[], includeOrphans: boolean): Promise<any[]> {
type NotesMap = {
@@ -378,7 +377,11 @@ export class ImportNotesProcessorService {
return;
}
- if (toot.directMessage) return;
+ const followers = toot.to.some((str: string) => str.includes('/followers'));
+
+ if (toot.directMessage || (!toot.to.includes('https://www.w3.org/ns/activitystreams#Public') || !followers)) return;
+
+ const visibility = followers ? 'home' : 'public';
const date = new Date(toot.object.published);
let text = undefined;
@@ -417,7 +420,7 @@ export class ImportNotesProcessorService {
}
}
- const createdNote = await this.noteCreateService.import(user, { createdAt: date, text: text, files: files, apMentions: new Array(0), cw: toot.object.sensitive ? toot.object.summary : null, reply: reply });
+ const createdNote = await this.noteCreateService.import(user, { createdAt: date, text: text, files: files, visibility: visibility, apMentions: new Array(0), cw: toot.object.sensitive ? toot.object.summary : null, reply: reply });
if (toot.childNotes) this.queueService.createImportMastoToDbJob(user, toot.childNotes, createdNote.id);
}