[bugfix/chore] Always set the status sensitive if media + content-warning present (#3308)

* always set the status sensitive flag to true if it has a content-warning with media

* whoops use attachment ids instead of mention ids ... 🤦
This commit is contained in:
kim 2024-09-16 11:38:12 +00:00 committed by GitHub
parent b2572b9e07
commit 6dd936fbe1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -495,22 +495,16 @@ func (p *Processor) processContent(ctx context.Context, parseMention gtsmodel.Pa
} }
// Gather all the database IDs from each of the gathered status mentions, tags, and emojis. // Gather all the database IDs from each of the gathered status mentions, tags, and emojis.
status.MentionIDs = gatherIDs(status.Mentions, func(mention *gtsmodel.Mention) string { return mention.ID }) status.MentionIDs = util.Gather(nil, status.Mentions, func(mention *gtsmodel.Mention) string { return mention.ID })
status.TagIDs = gatherIDs(status.Tags, func(tag *gtsmodel.Tag) string { return tag.ID }) status.TagIDs = util.Gather(nil, status.Tags, func(tag *gtsmodel.Tag) string { return tag.ID })
status.EmojiIDs = gatherIDs(status.Emojis, func(emoji *gtsmodel.Emoji) string { return emoji.ID }) status.EmojiIDs = util.Gather(nil, status.Emojis, func(emoji *gtsmodel.Emoji) string { return emoji.ID })
if status.ContentWarning != "" && len(status.AttachmentIDs) > 0 {
// If a content-warning is set, and
// the status contains media, always
// set the status sensitive flag.
status.Sensitive = util.Ptr(true)
}
return nil return nil
} }
// gatherIDs is a small utility function to gather IDs from a slice of type T.
func gatherIDs[T any](in []T, getID func(T) string) []string {
if getID == nil {
// move nil check out loop.
panic("nil getID function")
}
ids := make([]string, len(in))
for i, t := range in {
ids[i] = getID(t)
}
return ids
}