diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2024-11-14 19:32:08 -0500 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2024-11-20 22:03:17 -0500 |
| commit | a62e4f1cf2c99150d345917c290f13e5a48ab92e (patch) | |
| tree | 7751a544b151024a853ed8a66b9d2a116f50bed2 /packages/backend/src/core | |
| parent | merge: Bump develop version (!766) (diff) | |
| download | sharkey-a62e4f1cf2c99150d345917c290f13e5a48ab92e.tar.gz sharkey-a62e4f1cf2c99150d345917c290f13e5a48ab92e.tar.bz2 sharkey-a62e4f1cf2c99150d345917c290f13e5a48ab92e.zip | |
ignore `isNSFW` for pure renotes
Diffstat (limited to 'packages/backend/src/core')
| -rw-r--r-- | packages/backend/src/core/NoteCreateService.ts | 9 | ||||
| -rw-r--r-- | packages/backend/src/core/NoteEditService.ts | 9 |
2 files changed, 16 insertions, 2 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 1bc4599a60..ccc5bc0214 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -146,6 +146,8 @@ type Option = { app?: MiApp | null; }; +type PureRenoteOption = Option & { renote: MiNote } & ({ text?: null } | { cw?: null } | { reply?: null } | { poll?: null } | { files?: null | [] }); + @Injectable() export class NoteCreateService implements OnApplicationShutdown { #shutdownController = new AbortController(); @@ -412,7 +414,7 @@ export class NoteCreateService implements OnApplicationShutdown { if (user.host && !data.cw) { await this.federatedInstanceService.fetch(user.host).then(async i => { - if (i.isNSFW) { + if (i.isNSFW && !this.isPureRenote(data)) { data.cw = 'Instance is marked as NSFW'; } }); @@ -822,6 +824,11 @@ export class NoteCreateService implements OnApplicationShutdown { } @bindThis + private isPureRenote(note: Option): note is PureRenoteOption { + return this.isRenote(note) && !this.isQuote(note); + } + + @bindThis private isRenote(note: Option): note is Option & { renote: MiNote } { return note.renote != null; } diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts index d31958e5d4..6c456fb4a3 100644 --- a/packages/backend/src/core/NoteEditService.ts +++ b/packages/backend/src/core/NoteEditService.ts @@ -142,6 +142,8 @@ type Option = { editcount?: boolean | null; }; +type PureRenoteOption = Option & { renote: MiNote } & ({ text?: null } | { cw?: null } | { reply?: null } | { poll?: null } | { files?: null | [] }); + @Injectable() export class NoteEditService implements OnApplicationShutdown { #shutdownController = new AbortController(); @@ -442,7 +444,7 @@ export class NoteEditService implements OnApplicationShutdown { if (user.host && !data.cw) { await this.federatedInstanceService.fetch(user.host).then(async i => { - if (i.isNSFW) { + if (i.isNSFW && !this.isPureRenote(data)) { data.cw = 'Instance is marked as NSFW'; } }); @@ -788,6 +790,11 @@ export class NoteEditService implements OnApplicationShutdown { } @bindThis + private isPureRenote(note: Option): note is PureRenoteOption { + return this.isRenote(note) && !this.isQuote(note); + } + + @bindThis private isRenote(note: Option): note is Option & { renote: MiNote } { return note.renote != null; } |