event: add helper to append user ID to Mentions

This commit is contained in:
Tulir Asokan 2024-07-11 14:01:35 +03:00
commit 32e6f25c34

View file

@ -8,6 +8,7 @@ package event
import (
"encoding/json"
"slices"
"strconv"
"strings"
@ -212,6 +213,12 @@ type Mentions struct {
Room bool `json:"room,omitempty"`
}
func (m *Mentions) Add(userID id.UserID) {
if !slices.Contains(m.UserIDs, userID) {
m.UserIDs = append(m.UserIDs, userID)
}
}
type EncryptedFileInfo struct {
attachment.EncryptedFile
URL id.ContentURIString `json:"url"`