From 2f20034bb7a90c0491b765c492fa51c035b1aa78 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Fri, 22 May 2020 10:58:46 -0400 Subject: [PATCH] fix TAGMSG playback 1. TAGMSG were incorrectly being considered multilines, because Is512() was checking the wrong thing 2. Playback of TAGMSG should depend on event-playback, not on message-tags --- irc/channel.go | 2 +- irc/client.go | 2 +- irc/responsebuffer.go | 7 ++++++- irc/utils/text.go | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/irc/channel.go b/irc/channel.go index 6b0e2117..947ad9d4 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -1017,7 +1017,7 @@ func (channel *Channel) replayHistoryItems(rb *ResponseBuffer, items []history.I case history.Notice: rb.AddSplitMessageFromClient(item.Nick, item.AccountName, item.Tags, "NOTICE", chname, item.Message) case history.Tagmsg: - if rb.session.capabilities.Has(caps.MessageTags) { + if eventPlayback { rb.AddSplitMessageFromClient(item.Nick, item.AccountName, item.Tags, "TAGMSG", chname, item.Message) } case history.Join: diff --git a/irc/client.go b/irc/client.go index 6283b0a4..4445ad5c 100644 --- a/irc/client.go +++ b/irc/client.go @@ -897,7 +897,7 @@ func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.I } batchID = rb.StartNestedHistoryBatch(target) - allowTags := rb.session.capabilities.Has(caps.MessageTags) + allowTags := rb.session.capabilities.Has(caps.EventPlayback) for _, item := range items { var command string switch item.Type { diff --git a/irc/responsebuffer.go b/irc/responsebuffer.go index ffc40fca..9387a380 100644 --- a/irc/responsebuffer.go +++ b/irc/responsebuffer.go @@ -119,7 +119,12 @@ func (rb *ResponseBuffer) AddFromClient(time time.Time, msgid string, fromNickMa // AddSplitMessageFromClient adds a new split message from a specific client to our queue. func (rb *ResponseBuffer) AddSplitMessageFromClient(fromNickMask string, fromAccount string, tags map[string]string, command string, target string, message utils.SplitMessage) { if message.Is512() { - rb.AddFromClient(message.Time, message.Msgid, fromNickMask, fromAccount, tags, command, target, message.Message) + if message.Message == "" { + // XXX this is a TAGMSG + rb.AddFromClient(message.Time, message.Msgid, fromNickMask, fromAccount, tags, command, target) + } else { + rb.AddFromClient(message.Time, message.Msgid, fromNickMask, fromAccount, tags, command, target, message.Message) + } } else { if rb.session.capabilities.Has(caps.Multiline) { batch := rb.session.composeMultilineBatch(fromNickMask, fromAccount, tags, command, target, message) diff --git a/irc/utils/text.go b/irc/utils/text.go index 62c49eb5..82b07fdb 100644 --- a/irc/utils/text.go +++ b/irc/utils/text.go @@ -90,7 +90,7 @@ func (sm *SplitMessage) IsRestrictedCTCPMessage() bool { } func (sm *SplitMessage) Is512() bool { - return sm.Message != "" + return sm.Split == nil } // TokenLineBuilder is a helper for building IRC lines composed of delimited tokens,