mirror of
https://github.com/ergochat/ergo.git
synced 2025-01-03 00:22:34 +01:00
Send 477 ERR_NEEDREGGEDNICK when an unregistered user messages a +R user.
Fixes #1064.
This commit is contained in:
parent
1762a168e8
commit
23164054f6
@ -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"))
|
rb.Add(nil, server.name, ERR_NEEDREGGEDNICK, client.Nick(), tnick, client.t("Direct messages from unregistered users are temporarily restricted"))
|
||||||
return
|
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
|
nickMaskString := details.nickMask
|
||||||
accountName := details.accountName
|
accountName := details.accountName
|
||||||
var deliverySessions []*Session
|
var deliverySessions []*Session
|
||||||
// restrict messages appropriately when +R is set
|
deliverySessions = append(deliverySessions, user.Sessions()...)
|
||||||
// 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()...)
|
|
||||||
}
|
|
||||||
// all sessions of the sender, except the originating session, get a copy as well:
|
// all sessions of the sender, except the originating session, get a copy as well:
|
||||||
if client != user {
|
if client != user {
|
||||||
for _, session := range client.Sessions() {
|
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()
|
config := server.Config()
|
||||||
if !config.History.Enabled {
|
if !config.History.Enabled {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user