diff --git a/irc/handlers.go b/irc/handlers.go index 7217d4c3..1598b698 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2142,15 +2142,15 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi rb.Add(nil, server.name, ERR_NEEDREGGEDNICK, client.Nick(), tnick, client.t("Direct messages from unregistered users are temporarily restricted")) return } + // restrict messages appropriately when +R is set + if details.account == "" && user.HasMode(modes.RegisteredOnly) { + rb.Add(nil, server.name, ERR_NEEDREGGEDNICK, client.Nick(), tnick, client.t("You must be registered to send a direct message to this user")) + return + } nickMaskString := details.nickMask accountName := details.accountName var deliverySessions []*Session - // restrict messages appropriately when +R is set - // intentionally make the sending user think the message went through fine - allowedPlusR := details.account != "" || !user.HasMode(modes.RegisteredOnly) - if allowedPlusR { - deliverySessions = append(deliverySessions, user.Sessions()...) - } + deliverySessions = append(deliverySessions, user.Sessions()...) // all sessions of the sender, except the originating session, get a copy as well: if client != user { for _, session := range client.Sessions() { @@ -2183,10 +2183,6 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi } } - if !allowedPlusR { - return - } - config := server.Config() if !config.History.Enabled { return