Merge pull request #8379 from fschade/multi-user-sse-event

[full-ci] enhancement: allow sending multiple userIDs in one SSE event
This commit is contained in:
kobergj
2024-02-07 11:12:18 +01:00
committed by GitHub
9 changed files with 88 additions and 46 deletions
+2 -2
View File
@@ -4,9 +4,9 @@ import (
"encoding/json"
)
// SendSEE instructs the sse service to send a notification to a user
// SendSSE instructs the sse service to send one or multiple notifications
type SendSSE struct {
UserID string
UserIDs []string
Type string
Message []byte
}
@@ -50,10 +50,16 @@ func (i *Index) Load(index string) (map[string]string, error) {
}
// Add adds an entry to an index
// Consider calling AddAll() when trying to add multiple entries as every Add call has to lock the index
func (i *Index) Add(index, key string, value string) error {
return i.updateIndex(index, map[string]string{key: value}, []string{})
}
// AddAll adds multiple entries to the index
func (i *Index) AddAll(index string, m map[string]string) error {
return i.updateIndex(index, m, []string{})
}
// Remove removes an entry from the index
func (i *Index) Remove(index, key string) error {
return i.updateIndex(index, map[string]string{}, []string{key})