mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Merge commit 'f79b96a5ef0f6c4f57eee7f44ce2579b28a22098' into glitch-soc/merge-upstream
Conflicts: - `app/lib/feed_manager.rb`: Not a real conflict, but glitch-soc has an extra `populate_direct_feed` method. Added upstream's code. - `app/models/user_settings.rb`: Not a real conflict, glitch-soc has an extra setting textually-adjacent to a setting added upstream. Added upstream's setting. - `app/serializers/initial_state_serializer.rb`: Same. - `app/services/precompute_feed_service.rb`: Not a real conflict, glitch-soc has extra code for the direct feed. Added upstream's new code for populating lists.
This commit is contained in:
@@ -5,9 +5,12 @@ class PollExpirationValidator < ActiveModel::Validator
|
||||
MIN_EXPIRATION = 5.minutes.freeze
|
||||
|
||||
def validate(poll)
|
||||
# We have a `presence: true` check for this attribute already
|
||||
return if poll.expires_at.nil?
|
||||
|
||||
current_time = Time.now.utc
|
||||
|
||||
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_long')) if poll.expires_at.nil? || poll.expires_at - current_time > MAX_EXPIRATION
|
||||
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_short')) if poll.expires_at.present? && (poll.expires_at - current_time).ceil < MIN_EXPIRATION
|
||||
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_long')) if poll.expires_at - current_time > MAX_EXPIRATION
|
||||
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_short')) if (poll.expires_at - current_time).ceil < MIN_EXPIRATION
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user