Skip to content
Snippets Groups Projects

Prevent "mark instance as NSFW" from producing hellspawns

Merged Hazelnoot requested to merge fEmber/Sharkey:hazelnoot/fix-mark-as-nsfw-hellspawn into develop
All threads resolved!
2 files
+ 16
2
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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';
}
});
@@ -821,6 +823,11 @@ export class NoteCreateService implements OnApplicationShutdown {
if (!user.noindex) this.index(note);
}
@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;
Loading