From cbadb64748be97194a38c77a03aace0ac3c9a5e1 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 31 Mar 2020 19:37:34 +0200 Subject: [PATCH] Expose message-tags capability downstream Strip tags if the client doesn't support them. --- downstream.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/downstream.go b/downstream.go index cf6f55b..89c49e1 100644 --- a/downstream.go +++ b/downstream.go @@ -275,6 +275,7 @@ func (dc *downstreamConn) Close() error { // SendMessage queues a new outgoing message. It is safe to call from any // goroutine. func (dc *downstreamConn) SendMessage(msg *irc.Message) { + // TODO: strip tags if the client doesn't support them (see runNetwork) dc.outgoing <- msg } @@ -450,6 +451,8 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error { caps = append(caps, "sasl") } + caps = append(caps, "message-tags") + // TODO: multi-line replies dc.SendMessage(&irc.Message{ Prefix: dc.srv.prefix(), @@ -495,7 +498,7 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error { } switch name { - case "sasl": + case "sasl", "message-tags": dc.caps[name] = enable default: ack = false @@ -728,6 +731,9 @@ func (dc *downstreamConn) runNetwork(net *network, loadHistory bool) { } } + // TODO: can't be enabled/disabled on-the-fly + msgTagsEnabled := dc.caps["message-tags"] + consumer, ch := net.ring.NewConsumer(seqPtr) go func() { for { @@ -766,6 +772,10 @@ func (dc *downstreamConn) runNetwork(net *network, loadHistory bool) { panic("expected to consume a PRIVMSG message") } + if !msgTagsEnabled { + msg.Tags = nil + } + dc.SendMessage(msg) consumer.Consume() }