Expose message-tags capability downstream

Strip tags if the client doesn't support them.
This commit is contained in:
Simon Ser 2020-03-31 19:37:34 +02:00
parent 73ee7d237f
commit cbadb64748
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -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()
}