From 32e6f25c34b91cd07c7d8bc59282e7422541c762 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 11 Jul 2024 14:01:35 +0300 Subject: [PATCH] event: add helper to append user ID to Mentions --- event/message.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/event/message.go b/event/message.go index 5330d006..6ce405d6 100644 --- a/event/message.go +++ b/event/message.go @@ -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"`