From 8dfcf4728138d86f1701c13c723aacef95506fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Sun, 19 Feb 2017 22:26:48 +0100 Subject: [PATCH] Fix nick changes with op/voice --- storage/channel.go | 2 +- storage/channel_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/channel.go b/storage/channel.go index e358b916..06311e27 100644 --- a/storage/channel.go +++ b/storage/channel.go @@ -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 } diff --git a/storage/channel_test.go b/storage/channel_test.go index b2ef8e96..00fb7f8b 100644 --- a/storage/channel_test.go +++ b/storage/channel_test.go @@ -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") }