Allow retention_days of 0 to mean retain forever (closes #79)
Some checks failed
check / check (push) Has been cancelled
Some checks failed
check / check (push) Has been cancelled
Rewrites retention_days=0 to the RetentionForeverDays sentinel (365 * 1000) in Webhook.BeforeSave, so the GORM column default cannot win the race. The reaper skips retain-forever webhooks before building any query. Also bounds the reaper's cutoff arithmetic: a time.Duration is int64 nanoseconds, so day counts above MaxFiniteRetentionDays (106751) overflowed and wrapped the cutoff into the future, where created_at < cutoff matched every row and the sweep deleted everything. parseRetentionDays now rejects finite values above the ceiling, and retentionCutoff saturates so rows written by older versions cannot reach it either. Views render RetentionLabel() rather than the raw sentinel.
This commit was merged in pull request #96.
This commit is contained in:
@@ -18,6 +18,11 @@ const (
|
||||
testVersion = "test"
|
||||
// testContentType is the event content type used in tests.
|
||||
testContentType = "application/json"
|
||||
// testWebhookName is the Webhook.Name used in tests.
|
||||
testWebhookName = "test-webhook"
|
||||
// testForeverLabel is Webhook.RetentionLabel for a retain-forever
|
||||
// webhook.
|
||||
testForeverLabel = "forever"
|
||||
)
|
||||
|
||||
func setupTestDB(
|
||||
|
||||
Reference in New Issue
Block a user