[backend/api] Mark entire note as sensitive when any attachments are marked as such

This commit is contained in:
Laura Hausmann 2024-07-13 01:47:53 +02:00
parent 1dc942c78c
commit 248543528b
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -115,6 +115,8 @@ public class NoteRenderer(IOptions<Config.InstanceSection> config, MfmConverter
var quoteUri = note.IsQuote ? note.Renote?.Uri ?? note.Renote?.GetPublicUriOrNull(config.Value) : null; var quoteUri = note.IsQuote ? note.Renote?.Uri ?? note.Renote?.GetPublicUriOrNull(config.Value) : null;
var text = quoteUri != null ? note.Text + $"\n\nRE: {quoteUri}" : note.Text; var text = quoteUri != null ? note.Text + $"\n\nRE: {quoteUri}" : note.Text;
var sensitive = note.Cw != null || (attachments?.OfType<ASDocument>().Any(p => p.Sensitive == true) ?? false);
if (note.HasPoll) if (note.HasPoll)
{ {
var poll = await db.Polls.FirstOrDefaultAsync(p => p.Note == note); var poll = await db.Polls.FirstOrDefaultAsync(p => p.Note == note);
@ -145,7 +147,7 @@ public class NoteRenderer(IOptions<Config.InstanceSection> config, MfmConverter
MkContent = note.Text, MkContent = note.Text,
PublishedAt = note.CreatedAt, PublishedAt = note.CreatedAt,
UpdatedAt = note.UpdatedAt, UpdatedAt = note.UpdatedAt,
Sensitive = note.Cw != null, Sensitive = sensitive,
InReplyTo = replyId, InReplyTo = replyId,
Cc = cc, Cc = cc,
To = to, To = to,
@ -175,7 +177,7 @@ public class NoteRenderer(IOptions<Config.InstanceSection> config, MfmConverter
MkContent = note.Text, MkContent = note.Text,
PublishedAt = note.CreatedAt, PublishedAt = note.CreatedAt,
UpdatedAt = note.UpdatedAt, UpdatedAt = note.UpdatedAt,
Sensitive = note.Cw != null, Sensitive = sensitive,
InReplyTo = replyId, InReplyTo = replyId,
Cc = cc, Cc = cc,
To = to, To = to,