Add function to check if a comment is marked as spoiler

This commit is contained in:
bytedream 2022-06-23 16:44:34 +02:00
parent a283ba7247
commit 28070bd32d

View file

@ -71,6 +71,16 @@ func (c *Comment) Delete() error {
return nil return nil
} }
// IsSpoiler returns if the comment is marked as spoiler or not.
func (c *Comment) IsSpoiler() bool {
for _, flag := range c.Flags {
if flag == "spoiler" {
return true
}
}
return false
}
// MarkAsSpoiler marks the current comment as spoiler. Works only if the user has written the comment, // MarkAsSpoiler marks the current comment as spoiler. Works only if the user has written the comment,
// and it isn't already marked as spoiler. // and it isn't already marked as spoiler.
func (c *Comment) MarkAsSpoiler() error { func (c *Comment) MarkAsSpoiler() error {