Fix nick changes with op/voice

This commit is contained in:
Ken-Håvard Lieng 2017-02-19 22:26:48 +01:00
parent a5071fbd62
commit 8dfcf47281
2 changed files with 5 additions and 1 deletions

View File

@ -108,7 +108,7 @@ func (c *ChannelStore) FindUserChannels(user, server string) []string {
c.userLock.Lock()
for channel, users := range c.users[server] {
for _, nick := range users {
if user == nick {
if user == strings.TrimLeft(nick, "@+") {
channels = append(channels, channel)
break
}

View File

@ -66,9 +66,13 @@ func TestFindUserChannels(t *testing.T) {
channelStore.AddUser("user", "srv", "#chan2")
channelStore.AddUser("user2", "srv", "#chan3")
channelStore.AddUser("user", "srv2", "#chan4")
channelStore.AddUser("@gotop", "srv", "#chan1")
channels := channelStore.FindUserChannels("user", "srv")
assert.Len(t, channels, 2)
assert.Contains(t, channels, "#chan1")
assert.Contains(t, channels, "#chan2")
channels = channelStore.FindUserChannels("gotop", "srv")
assert.Len(t, channels, 1)
assert.Contains(t, channels, "#chan1")
}