Ignored people still show up when they send private /msg

This commit is contained in:
Abdelkader Bouadjadja 2020-04-30 05:09:21 +04:00
parent fde04365ac
commit 6fe0b40327
3 changed files with 13 additions and 0 deletions

View File

@ -183,6 +183,10 @@ func (m PrivateMsg) To() *User {
return m.to
}
func (m PrivateMsg) From() *User {
return m.from
}
func (m PrivateMsg) Render(t *Theme) string {
s := fmt.Sprintf("[PM from %s] %s", m.from.Name(), m.body)
if t == nil {

View File

@ -89,6 +89,14 @@ func (r *Room) HandleMsg(m message.Message) {
}
case message.MessageTo:
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)
default:
fromMsg, _ := m.(message.MessageFrom)

View File

@ -107,6 +107,7 @@ func TestIgnore(t *testing.T) {
// when an emote is sent by an ignored user, it should not be displayed
ch.Send(message.NewEmoteMsg("crying", ignored.user))
if ignorer.user.HasMessages() {
t.Fatal("should not have emote messages")
}