mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 02:43:09 -06:00
Make removeUser public
This commit is contained in:
parent
14850f9c33
commit
48ca0d963f
|
|
@ -85,12 +85,12 @@ func (t *TypingCache) addUser(userID, roomID string, expiryTimer *time.Timer) {
|
||||||
// This removes the user.
|
// This removes the user.
|
||||||
func (t *TypingCache) timeoutCallback(userID, roomID string) func() {
|
func (t *TypingCache) timeoutCallback(userID, roomID string) func() {
|
||||||
return func() {
|
return func() {
|
||||||
t.removeUser(userID, roomID)
|
t.RemoveUser(userID, roomID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// removeUser with mutex lock & stop the timer.
|
// RemoveUser with mutex lock & stop the timer.
|
||||||
func (t *TypingCache) removeUser(userID, roomID string) {
|
func (t *TypingCache) RemoveUser(userID, roomID string) {
|
||||||
t.Lock()
|
t.Lock()
|
||||||
defer t.Unlock()
|
defer t.Unlock()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ func TestTypingCache(t *testing.T) {
|
||||||
testGetTypingUsers(t, tCache)
|
testGetTypingUsers(t, tCache)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("removeUser", func(t *testing.T) {
|
t.Run("RemoveUser", func(t *testing.T) {
|
||||||
testRemoveUser(t, tCache)
|
testRemoveUser(t, tCache)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +90,7 @@ func testRemoveUser(t *testing.T, tCache *TypingCache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
length := len(tt.userIDs)
|
length := len(tt.userIDs)
|
||||||
tCache.removeUser(tt.userIDs[length-1], tt.roomID)
|
tCache.RemoveUser(tt.userIDs[length-1], tt.roomID)
|
||||||
expLeftUsers := tt.userIDs[:length-1]
|
expLeftUsers := tt.userIDs[:length-1]
|
||||||
if leftUsers := tCache.GetTypingUsers(tt.roomID); !test.UnsortedStringSliceEqual(leftUsers, expLeftUsers) {
|
if leftUsers := tCache.GetTypingUsers(tt.roomID); !test.UnsortedStringSliceEqual(leftUsers, expLeftUsers) {
|
||||||
t.Errorf("Response after removal is unexpected. Want = %s, got = %s", leftUsers, expLeftUsers)
|
t.Errorf("Response after removal is unexpected. Want = %s, got = %s", leftUsers, expLeftUsers)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue