mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-06-06 10:23:03 +03:00
Ignored people still show up when they /me
emote
This commit is contained in:
parent
403bb5911b
commit
7169ee1240
@ -138,9 +138,7 @@ func (m PublicMsg) String() string {
|
|||||||
return fmt.Sprintf("%s: %s", m.from.Name(), m.body)
|
return fmt.Sprintf("%s: %s", m.from.Name(), m.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EmoteMsg is a /me message sent to the room. It specifically does not
|
// EmoteMsg is a /me message sent to the room.
|
||||||
// extend PublicMsg because it doesn't implement MessageFrom to allow the
|
|
||||||
// sender to see the emote.
|
|
||||||
type EmoteMsg struct {
|
type EmoteMsg struct {
|
||||||
Msg
|
Msg
|
||||||
from *User
|
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 {
|
func (m EmoteMsg) Render(t *Theme) string {
|
||||||
return fmt.Sprintf("** %s %s", m.from.Name(), m.body)
|
return fmt.Sprintf("** %s %s", m.from.Name(), m.body)
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,12 @@ func TestIgnore(t *testing.T) {
|
|||||||
t.Fatalf("should have %d ignored users, has %d", 1, len(ignoredList))
|
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
|
// when a message is sent from the ignored user, it is delivered to non-ignoring users
|
||||||
ch.Send(message.NewPublicMsg("hello", ignored.user))
|
ch.Send(message.NewPublicMsg("hello", ignored.user))
|
||||||
other.user.HandleMsg(other.user.ConsumeOne())
|
other.user.HandleMsg(other.user.ConsumeOne())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user