Request invite-notify to upstreams

... and do not forward INVITEs to downstreams that do not support the
capability.

The downstream capability can be permanent because there is no way for a
client to get the list of people invited to a channel, thus no state can
be corrupted.
This commit is contained in:
Hubert Hirtz 2021-01-21 09:22:15 +01:00 committed by Simon Ser
parent 62f1207437
commit 5aa15d5628
2 changed files with 13 additions and 6 deletions

View File

@ -67,6 +67,7 @@ var permanentDownstreamCaps = map[string]string{
"batch": "",
"cap-notify": "",
"echo-message": "",
"invite-notify": "",
"message-tags": "",
"sasl": "PLAIN",
"server-time": "",

View File

@ -27,6 +27,7 @@ var permanentUpstreamCaps = map[string]bool{
"away-notify": true,
"batch": true,
"extended-join": true,
"invite-notify": true,
"labeled-response": true,
"message-tags": true,
"multi-prefix": true,
@ -1279,7 +1280,12 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
return err
}
weAreInvited := nick == uc.nick
uc.forEachDownstream(func(dc *downstreamConn) {
if !weAreInvited && !dc.caps["invite-notify"] {
return
}
dc.SendMessage(&irc.Message{
Prefix: dc.marshalUserPrefix(uc.network, msg.Prefix),
Command: "INVITE",