From 737697d1d4471970b23311848a3693fa76984ed6 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 12 May 2022 16:43:11 -0400 Subject: [PATCH] exempt operators from history cutoffs See #1593; this enables a client-side implementation of bulk deletion --- irc/server.go | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/irc/server.go b/irc/server.go index 7d8b96d6..b4bce531 100644 --- a/irc/server.go +++ b/irc/server.go @@ -972,25 +972,28 @@ func (server *Server) GetHistorySequence(providedChannel *Channel, client *Clien } var cutoff time.Time - if config.History.Restrictions.ExpireTime != 0 { - cutoff = time.Now().UTC().Add(-time.Duration(config.History.Restrictions.ExpireTime)) - } - // #836: registration date cutoff is always enforced for DMs - // either way, take the later of the two cutoffs - if restriction == HistoryCutoffRegistrationTime || channel == nil { - regCutoff := client.historyCutoff() - if regCutoff.After(cutoff) { - cutoff = regCutoff + // #1593: cutoff is ignored for operators + if !client.HasRoleCapabs("history") { + if config.History.Restrictions.ExpireTime != 0 { + cutoff = time.Now().UTC().Add(-time.Duration(config.History.Restrictions.ExpireTime)) } - } else if restriction == HistoryCutoffJoinTime { - if joinTimeCutoff.After(cutoff) { - cutoff = joinTimeCutoff + // #836: registration date cutoff is always enforced for DMs + // either way, take the later of the two cutoffs + if restriction == HistoryCutoffRegistrationTime || channel == nil { + regCutoff := client.historyCutoff() + if regCutoff.After(cutoff) { + cutoff = regCutoff + } + } else if restriction == HistoryCutoffJoinTime { + if joinTimeCutoff.After(cutoff) { + cutoff = joinTimeCutoff + } } - } - // #836 again: grace period is never applied to DMs - if !cutoff.IsZero() && channel != nil && restriction != HistoryCutoffJoinTime { - cutoff = cutoff.Add(-time.Duration(config.History.Restrictions.GracePeriod)) + // #836 again: grace period is never applied to DMs + if !cutoff.IsZero() && channel != nil && restriction != HistoryCutoffJoinTime { + cutoff = cutoff.Add(-time.Duration(config.History.Restrictions.GracePeriod)) + } } if hist != nil {