0
0
Fork 0

Add retention policy for cached content and media (#19232)

This commit is contained in:
Eugen Rochko 2022-09-27 03:08:19 +02:00 committed by GitHub
parent 3e0999cd11
commit 5c9abdeff1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 559 additions and 135 deletions

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
class ContentRetentionPolicy
def self.current
new
end
def media_cache_retention_period
retention_period Setting.media_cache_retention_period
end
def content_cache_retention_period
retention_period Setting.content_cache_retention_period
end
def backups_retention_period
retention_period Setting.backups_retention_period
end
private
def retention_period(value)
value.days if value.is_a?(Integer) && value.positive?
end
end

View file

@ -32,6 +32,9 @@ class Form::AdminSettings
show_domain_blocks_rationale
noindex
require_invite_text
media_cache_retention_period
content_cache_retention_period
backups_retention_period
).freeze
BOOLEAN_KEYS = %i(
@ -64,6 +67,7 @@ class Form::AdminSettings
validates :bootstrap_timeline_accounts, existing_username: { multiple: true }
validates :show_domain_blocks, inclusion: { in: %w(disabled users all) }
validates :show_domain_blocks_rationale, inclusion: { in: %w(disabled users all) }
validates :media_cache_retention_period, :content_cache_retention_period, :backups_retention_period, numericality: { only_integer: true }
def initialize(_attributes = {})
super