From 3f74612e2b9e8417aba3fd1888b27e8c27d0843a Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Tue, 15 Aug 2023 20:29:57 -0400 Subject: [PATCH] implement draft/no-implicit-names --- gencapdefs.py | 6 ++++++ irc/caps/defs.go | 7 ++++++- irc/channel.go | 8 ++++++-- irc/handlers.go | 4 +++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gencapdefs.py b/gencapdefs.py index 00ba435e..e1cfbc7f 100644 --- a/gencapdefs.py +++ b/gencapdefs.py @@ -213,6 +213,12 @@ CAPDEFS = [ url="https://github.com/ircv3/ircv3-specifications/pull/506", standard="IRCv3", ), + CapDef( + identifier="NoImplicitNames", + name="draft/no-implicit-names", + url="https://github.com/ircv3/ircv3-specifications/pull/527", + standard="proposed IRCv3", + ), ] def validate_defs(): diff --git a/irc/caps/defs.go b/irc/caps/defs.go index aa48a649..18ff5759 100644 --- a/irc/caps/defs.go +++ b/irc/caps/defs.go @@ -7,7 +7,7 @@ package caps const ( // number of recognized capabilities: - numCapabs = 33 + numCapabs = 34 // length of the uint32 array that represents the bitset: bitsetLen = 2 ) @@ -65,6 +65,10 @@ const ( // https://github.com/ircv3/ircv3-specifications/pull/398 Multiline Capability = iota + // NoImplicitNames is the proposed IRCv3 capability named "draft/no-implicit-names": + // https://github.com/ircv3/ircv3-specifications/pull/527 + NoImplicitNames Capability = iota + // Persistence is the proposed IRCv3 capability named "draft/persistence": // https://github.com/ircv3/ircv3-specifications/pull/503 Persistence Capability = iota @@ -162,6 +166,7 @@ var ( "draft/languages", "draft/message-redaction", "draft/multiline", + "draft/no-implicit-names", "draft/persistence", "draft/pre-away", "draft/read-marker", diff --git a/irc/channel.go b/irc/channel.go index 4680958c..cb199c08 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -884,7 +884,9 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp if rb.session.client == client { // don't send topic and names for a SAJOIN of a different client channel.SendTopic(client, rb, false) - channel.Names(client, rb) + if !rb.session.capabilities.Has(caps.NoImplicitNames) { + channel.Names(client, rb) + } } else { // ensure that SAJOIN sends a MODE line to the originating client, if applicable if givenMode != 0 { @@ -975,7 +977,9 @@ func (channel *Channel) playJoinForSession(session *Session) { sessionRb.Add(nil, client.server.name, "MARKREAD", chname, client.GetReadMarker(chcfname)) } channel.SendTopic(client, sessionRb, false) - channel.Names(client, sessionRb) + if !session.capabilities.Has(caps.NoImplicitNames) { + channel.Names(client, sessionRb) + } sessionRb.Send(false) } diff --git a/irc/handlers.go b/irc/handlers.go index f3db4fe3..9778b32e 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -3169,7 +3169,9 @@ func renameHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo targetRb.Add(nil, targetPrefix, "JOIN", newName) } channel.SendTopic(mcl, targetRb, false) - channel.Names(mcl, targetRb) + if !targetRb.session.capabilities.Has(caps.NoImplicitNames) { + channel.Names(mcl, targetRb) + } } if mcl != client { targetRb.Send(false)