[PATCH v2] Request invite-notify to upstreams
Export this patch
... 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.
Right. The cap is more of a marker saying "the client won't freak out when
receiving these INVITE messages".
---
downstream.go | 13 +++++++ ------
upstream.go | 4 ++++
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/downstream.go b/downstream.go
index 200345f..e2824d2 100644
--- a/downstream.go
+++ b/downstream.go
@@ -64,12 +64,13 @@ const illegalNickChars = " :@!*?"
// permanentDownstreamCaps is the list of always-supported downstream
// capabilities.
var permanentDownstreamCaps = map[string]string{
- "batch": "",
- "cap-notify": "",
- "echo-message": "",
- "message-tags": "",
- "sasl": "PLAIN",
- "server-time": "",
+ "batch": "",
+ "cap-notify": "",
+ "echo-message": "",
+ "invite-notify": "",
+ "message-tags": "",
+ "sasl": "PLAIN",
+ "server-time": "",
}
// needAllDownstreamCaps is the list of downstream capabilities that
diff --git a/upstream.go b/upstream.go
index 6cf035d..61aa2df 100644
--- a/upstream.go
+++ b/upstream.go
@@ -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,
@@ -1341,6 +1342,9 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
}
uc.forEachDownstream(func(dc *downstreamConn) {
+ if !dc.caps["invite-notify"] {
+ return
+ }
The INVITE messages also get sent to the invitee without invite-notify. Don't
we need to check that we aren't the invitee here as well?
dc.SendMessage(&irc.Message{
Prefix: dc.marshalUserPrefix(uc.network, msg.Prefix),
Command: "INVITE",
--
2.30.0