Take map lock

This commit is contained in:
Neil Alexander 2022-04-06 12:55:37 +01:00
parent 3c73ec6b9f
commit 68c1a13195
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -250,6 +250,8 @@ func (n *Notifier) OnNewPresence(
}
func (n *Notifier) SharedUsers(userID string) (sharedUsers []string) {
n.mapLock.RLock()
defer n.mapLock.RUnlock()
for roomID, users := range n.roomIDToJoinedUsers {
if _, ok := users[userID]; ok {
sharedUsers = append(sharedUsers, n.JoinedUsers(roomID)...)
@ -259,6 +261,8 @@ func (n *Notifier) SharedUsers(userID string) (sharedUsers []string) {
}
func (n *Notifier) IsSharedUser(userA, userB string) bool {
n.mapLock.RLock()
defer n.mapLock.RUnlock()
var okA, okB bool
for _, users := range n.roomIDToJoinedUsers {
_, okA = users[userA]