1
0
mirror of https://github.com/mastodon/mastodon synced 2024-11-23 22:56:20 +09:00

Use EXPIRATION_DURATIONS constant in CustomFilter class (#30088)

This commit is contained in:
Matt Jankowski 2024-04-29 05:01:46 -04:00 committed by GitHub
parent 4527e012da
commit f0c9cbaf3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -28,6 +28,8 @@ class CustomFilter < ApplicationRecord
account
).freeze
EXPIRATION_DURATIONS = [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].freeze
include Expireable
include Redisable
@ -52,7 +54,7 @@ class CustomFilter < ApplicationRecord
return @expires_in if defined?(@expires_in)
return nil if expires_at.nil?
[30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].find { |expires_in| expires_in.from_now >= expires_at }
EXPIRATION_DURATIONS.find { |expires_in| expires_in.from_now >= expires_at }
end
def irreversible=(value)

View File

@ -6,7 +6,7 @@
wrapper: :with_label
.fields-row__column.fields-row__column-6.fields-group
= f.input :expires_in,
collection: [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].map(&:to_i),
collection: CustomFilter::EXPIRATION_DURATIONS.map(&:to_i),
include_blank: I18n.t('invites.expires_in_prompt'),
label_method: ->(i) { I18n.t("invites.expires_in.#{i}") },
wrapper: :with_label