3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 03:49:27 +01:00

Merge pull request #1580 from ajaspers/plusR

Send 477 ERR_NEEDREGGEDNICK when an unregistered user messages a +R user.
This commit is contained in:
Shivaram Lingamneni 2021-03-04 17:14:45 -05:00 committed by GitHub
commit 26cb622f92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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