Ignored people still show up when they /me emote

This commit is contained in:
Abdelkader Bouadjadja committed 2020-04-30 00:28:06 +04:00
1 parent 403bb5911b
commit 7169ee1240
2 files changed
+11 -3

No files matched your search

+5 -3
View File
@@ -138,9 +138,7 @@ func (m PublicMsg) String() string {
return fmt.Sprintf("%s: %s", m.from.Name(), m.body)
}
// EmoteMsg is a /me message sent to the room. It specifically does not
// extend PublicMsg because it doesn't implement MessageFrom to allow the
// sender to see the emote.
// EmoteMsg is a /me message sent to the room.
type EmoteMsg struct {
Msg
from *User
@@ -156,6 +154,10 @@ func NewEmoteMsg(body string, from *User) *EmoteMsg {
}
}
func (m EmoteMsg) From() *User {
return m.from
}
func (m EmoteMsg) Render(t *Theme) string {
return fmt.Sprintf("** %s %s", m.from.Name(), m.body)
}
+6
View File
@@ -105,6 +105,12 @@ func TestIgnore(t *testing.T) {
t.Fatalf("should have %d ignored users, has %d", 1, len(ignoredList))
}
// ignoring the same user twice returns an error message and doesn't add the user twice
ch.Send(message.NewEmoteMsg("crying", ignored.user))
if ignorer.user.HasMessages() {
t.Fatal("should not have emote messages")
}
// when a message is sent from the ignored user, it is delivered to non-ignoring users
ch.Send(message.NewPublicMsg("hello", ignored.user))
other.user.HandleMsg(other.user.ConsumeOne())