Added new clear function-calls for the recent-stored-events and as well the permanent-block list

This commit is contained in:
2026-02-21 17:23:33 +01:00
parent c85d51edd6
commit 3e06cfc1ab
12 changed files with 138 additions and 11 deletions

View File

@@ -878,6 +878,18 @@ WHERE 1=1`
return result, rows.Err()
}
// Deletes all ban event records.
func ClearBanEvents(ctx context.Context) (int64, error) {
if db == nil {
return 0, errors.New("storage not initialised")
}
res, err := db.ExecContext(ctx, `DELETE FROM ban_events`)
if err != nil {
return 0, err
}
return res.RowsAffected()
}
// =========================================================================
// Recurring IP Statistics
// =========================================================================
@@ -1263,3 +1275,15 @@ func IsPermanentBlockActive(ctx context.Context, ip, integration string) (bool,
}
return rec.Status == "blocked", nil
}
// Deletes all permanent block records.
func ClearPermanentBlocks(ctx context.Context) (int64, error) {
if db == nil {
return 0, errors.New("storage not initialised")
}
res, err := db.ExecContext(ctx, `DELETE FROM permanent_blocks`)
if err != nil {
return 0, err
}
return res.RowsAffected()
}