Browse Source

exempt operators from history cutoffs

See #1593; this enables a client-side implementation of bulk deletion
tags/v2.10.0-rc1
Shivaram Lingamneni 2 years ago
parent
commit
737697d1d4
1 changed files with 19 additions and 16 deletions
  1. 19
    16
      irc/server.go

+ 19
- 16
irc/server.go View File

972
 	}
972
 	}
973
 
973
 
974
 	var cutoff time.Time
974
 	var cutoff time.Time
975
-	if config.History.Restrictions.ExpireTime != 0 {
976
-		cutoff = time.Now().UTC().Add(-time.Duration(config.History.Restrictions.ExpireTime))
977
-	}
978
-	// #836: registration date cutoff is always enforced for DMs
979
-	// either way, take the later of the two cutoffs
980
-	if restriction == HistoryCutoffRegistrationTime || channel == nil {
981
-		regCutoff := client.historyCutoff()
982
-		if regCutoff.After(cutoff) {
983
-			cutoff = regCutoff
975
+	// #1593: cutoff is ignored for operators
976
+	if !client.HasRoleCapabs("history") {
977
+		if config.History.Restrictions.ExpireTime != 0 {
978
+			cutoff = time.Now().UTC().Add(-time.Duration(config.History.Restrictions.ExpireTime))
984
 		}
979
 		}
985
-	} else if restriction == HistoryCutoffJoinTime {
986
-		if joinTimeCutoff.After(cutoff) {
987
-			cutoff = joinTimeCutoff
980
+		// #836: registration date cutoff is always enforced for DMs
981
+		// either way, take the later of the two cutoffs
982
+		if restriction == HistoryCutoffRegistrationTime || channel == nil {
983
+			regCutoff := client.historyCutoff()
984
+			if regCutoff.After(cutoff) {
985
+				cutoff = regCutoff
986
+			}
987
+		} else if restriction == HistoryCutoffJoinTime {
988
+			if joinTimeCutoff.After(cutoff) {
989
+				cutoff = joinTimeCutoff
990
+			}
988
 		}
991
 		}
989
-	}
990
 
992
 
991
-	// #836 again: grace period is never applied to DMs
992
-	if !cutoff.IsZero() && channel != nil && restriction != HistoryCutoffJoinTime {
993
-		cutoff = cutoff.Add(-time.Duration(config.History.Restrictions.GracePeriod))
993
+		// #836 again: grace period is never applied to DMs
994
+		if !cutoff.IsZero() && channel != nil && restriction != HistoryCutoffJoinTime {
995
+			cutoff = cutoff.Add(-time.Duration(config.History.Restrictions.GracePeriod))
996
+		}
994
 	}
997
 	}
995
 
998
 
996
 	if hist != nil {
999
 	if hist != nil {

Loading…
Cancel
Save