ignore isNSFW for pure renotes

This commit is contained in:
Hazelnoot 2024-11-14 19:32:08 -05:00
parent 41536480ce
commit a62e4f1cf2
2 changed files with 16 additions and 2 deletions

View file

@ -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;

View file

@ -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';
}
});
@ -787,6 +789,11 @@ export class NoteEditService 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;