Expose message-tags capability downstream
Strip tags if the client doesn't support them.
This commit is contained in:
parent
73ee7d237f
commit
cbadb64748
@ -275,6 +275,7 @@ func (dc *downstreamConn) Close() error {
|
|||||||
// SendMessage queues a new outgoing message. It is safe to call from any
|
// SendMessage queues a new outgoing message. It is safe to call from any
|
||||||
// goroutine.
|
// goroutine.
|
||||||
func (dc *downstreamConn) SendMessage(msg *irc.Message) {
|
func (dc *downstreamConn) SendMessage(msg *irc.Message) {
|
||||||
|
// TODO: strip tags if the client doesn't support them (see runNetwork)
|
||||||
dc.outgoing <- msg
|
dc.outgoing <- msg
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,6 +451,8 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
|
|||||||
caps = append(caps, "sasl")
|
caps = append(caps, "sasl")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
caps = append(caps, "message-tags")
|
||||||
|
|
||||||
// TODO: multi-line replies
|
// TODO: multi-line replies
|
||||||
dc.SendMessage(&irc.Message{
|
dc.SendMessage(&irc.Message{
|
||||||
Prefix: dc.srv.prefix(),
|
Prefix: dc.srv.prefix(),
|
||||||
@ -495,7 +498,7 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch name {
|
switch name {
|
||||||
case "sasl":
|
case "sasl", "message-tags":
|
||||||
dc.caps[name] = enable
|
dc.caps[name] = enable
|
||||||
default:
|
default:
|
||||||
ack = false
|
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)
|
consumer, ch := net.ring.NewConsumer(seqPtr)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@ -766,6 +772,10 @@ func (dc *downstreamConn) runNetwork(net *network, loadHistory bool) {
|
|||||||
panic("expected to consume a PRIVMSG message")
|
panic("expected to consume a PRIVMSG message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !msgTagsEnabled {
|
||||||
|
msg.Tags = nil
|
||||||
|
}
|
||||||
|
|
||||||
dc.SendMessage(msg)
|
dc.SendMessage(msg)
|
||||||
consumer.Consume()
|
consumer.Consume()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user