Skip to content

Commit

Permalink
exempt operators from history cutoffs
Browse files Browse the repository at this point in the history
See ergochat#1593; this enables a client-side implementation of bulk deletion
  • Loading branch information
slingamn committed May 12, 2022
1 parent dd75eb1 commit 737697d
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions irc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 737697d

Please sign in to comment.