AddPaths adds paths to every chat in chatIDs and notifies their subscribers. Zero-value UUIDs are silently skipped.
(chatIDs []uuid.UUID, paths []string)
| 26 | // AddPaths adds paths to every chat in chatIDs and notifies |
| 27 | // their subscribers. Zero-value UUIDs are silently skipped. |
| 28 | func (ps *PathStore) AddPaths(chatIDs []uuid.UUID, paths []string) { |
| 29 | affected := make([]uuid.UUID, 0, len(chatIDs)) |
| 30 | for _, id := range chatIDs { |
| 31 | if id != uuid.Nil { |
| 32 | affected = append(affected, id) |
| 33 | } |
| 34 | } |
| 35 | if len(affected) == 0 { |
| 36 | return |
| 37 | } |
| 38 | |
| 39 | ps.mu.Lock() |
| 40 | for _, id := range affected { |
| 41 | m, ok := ps.chatPaths[id] |
| 42 | if !ok { |
| 43 | m = make(map[string]struct{}) |
| 44 | ps.chatPaths[id] = m |
| 45 | } |
| 46 | for _, p := range paths { |
| 47 | m[p] = struct{}{} |
| 48 | } |
| 49 | } |
| 50 | ps.mu.Unlock() |
| 51 | |
| 52 | ps.notifySubscribers(affected) |
| 53 | } |
| 54 | |
| 55 | // Notify sends a signal to all subscribers of the given chat IDs |
| 56 | // without adding any paths. Zero-value UUIDs are silently skipped. |