From 17a89838b88b30afab61384d36929fc4c6dae326 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 20 Feb 2020 02:06:13 -0500 Subject: [PATCH] fix Client.historyStatus --- irc/client.go | 15 +++++++++------ irc/handlers.go | 4 ++-- irc/server.go | 9 ++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/irc/client.go b/irc/client.go index 82bd20b1..2d95dae7 100644 --- a/irc/client.go +++ b/irc/client.go @@ -353,7 +353,7 @@ func (server *Server) AddAlwaysOnClient(account ClientAccount, chnames []string) } func (client *Client) resizeHistory(config *Config) { - _, ephemeral := client.historyStatus(config) + _, ephemeral, _ := client.historyStatus(config) if ephemeral { client.history.Resize(config.History.ClientLength, config.History.AutoresizeWindow) } else { @@ -756,7 +756,7 @@ func (session *Session) playResume() { } } } - _, cEphemeral := client.historyStatus(config) + _, cEphemeral, _ := client.historyStatus(config) if cEphemeral { lastDiscarded := client.history.LastDiscarded() if oldestLostMessage.Before(lastDiscarded) { @@ -1543,20 +1543,23 @@ func (client *Client) attemptAutoOper(session *Session) { } } -func (client *Client) historyStatus(config *Config) (persistent, ephemeral bool) { +func (client *Client) historyStatus(config *Config) (persistent, ephemeral bool, target string) { if !config.History.Enabled { - return false, false + return } else if !config.History.Persistent.Enabled { - return false, true + ephemeral = true + return } client.stateMutex.RLock() alwaysOn := client.alwaysOn historyStatus := client.accountSettings.DMHistory + target = client.nickCasefolded client.stateMutex.RUnlock() if !alwaysOn { - return false, true + ephemeral = true + return } historyStatus = historyEnabled(config.History.Persistent.DirectMessages, historyStatus) diff --git a/irc/handlers.go b/irc/handlers.go index 314e9dd9..ad92c8d3 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -1975,8 +1975,8 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi } targetedItem := item targetedItem.Params[0] = tnick - cPersistent, cEphemeral := client.historyStatus(config) - tPersistent, tEphemeral := user.historyStatus(config) + cPersistent, cEphemeral, _ := client.historyStatus(config) + tPersistent, tEphemeral, _ := user.historyStatus(config) // add to ephemeral history if cEphemeral { targetedItem.CfCorrespondent = tDetails.nickCasefolded diff --git a/irc/server.go b/irc/server.go index 0c454e49..1fb20669 100644 --- a/irc/server.go +++ b/irc/server.go @@ -867,10 +867,13 @@ func (server *Server) GetHistorySequence(providedChannel *Channel, client *Clien var sender, recipient string var hist *history.Buffer if target == "*" { - if client.AlwaysOn() { - recipient = client.NickCasefolded() - } else { + persistent, ephemeral, target := client.historyStatus(config) + if persistent { + recipient = target + } else if ephemeral { hist = &client.history + } else { + return } } else { channel = providedChannel