mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-07-02 03:34:29 +02:00
Ignored people still show up when they send private /msg
This commit is contained in:
parent
fde04365ac
commit
6fe0b40327
@ -183,6 +183,10 @@ func (m PrivateMsg) To() *User {
|
|||||||
return m.to
|
return m.to
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m PrivateMsg) From() *User {
|
||||||
|
return m.from
|
||||||
|
}
|
||||||
|
|
||||||
func (m PrivateMsg) Render(t *Theme) string {
|
func (m PrivateMsg) Render(t *Theme) string {
|
||||||
s := fmt.Sprintf("[PM from %s] %s", m.from.Name(), m.body)
|
s := fmt.Sprintf("[PM from %s] %s", m.from.Name(), m.body)
|
||||||
if t == nil {
|
if t == nil {
|
||||||
|
@ -89,6 +89,14 @@ func (r *Room) HandleMsg(m message.Message) {
|
|||||||
}
|
}
|
||||||
case message.MessageTo:
|
case message.MessageTo:
|
||||||
user := m.To()
|
user := m.To()
|
||||||
|
if _, ok := m.(*message.PrivateMsg); ok {
|
||||||
|
fromMsg, _ := m.(message.MessageFrom)
|
||||||
|
if fromMsg != nil && user.Ignored.In(fromMsg.From().ID()) {
|
||||||
|
// Skip because ignored
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
user.Send(m)
|
user.Send(m)
|
||||||
default:
|
default:
|
||||||
fromMsg, _ := m.(message.MessageFrom)
|
fromMsg, _ := m.(message.MessageFrom)
|
||||||
|
@ -107,6 +107,7 @@ func TestIgnore(t *testing.T) {
|
|||||||
|
|
||||||
// when an emote is sent by an ignored user, it should not be displayed
|
// when an emote is sent by an ignored user, it should not be displayed
|
||||||
ch.Send(message.NewEmoteMsg("crying", ignored.user))
|
ch.Send(message.NewEmoteMsg("crying", ignored.user))
|
||||||
|
|
||||||
if ignorer.user.HasMessages() {
|
if ignorer.user.HasMessages() {
|
||||||
t.Fatal("should not have emote messages")
|
t.Fatal("should not have emote messages")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user