mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Update location of unused MIN_SCHEDULE_OFFSET
constant
This commit is contained in:
parent
584b1524dd
commit
4335385612
3 changed files with 8 additions and 5 deletions
|
@ -15,6 +15,7 @@ class ScheduledStatus < ApplicationRecord
|
||||||
|
|
||||||
TOTAL_LIMIT = 300
|
TOTAL_LIMIT = 300
|
||||||
DAILY_LIMIT = 25
|
DAILY_LIMIT = 25
|
||||||
|
MINIMUM_OFFSET = 5.minutes.freeze
|
||||||
|
|
||||||
belongs_to :account, inverse_of: :scheduled_statuses
|
belongs_to :account, inverse_of: :scheduled_statuses
|
||||||
has_many :media_attachments, inverse_of: :scheduled_status, dependent: :nullify
|
has_many :media_attachments, inverse_of: :scheduled_status, dependent: :nullify
|
||||||
|
@ -26,7 +27,7 @@ class ScheduledStatus < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def validate_future_date
|
def validate_future_date
|
||||||
errors.add(:scheduled_at, I18n.t('scheduled_statuses.too_soon')) if scheduled_at.present? && scheduled_at <= Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET
|
errors.add(:scheduled_at, I18n.t('scheduled_statuses.too_soon')) if scheduled_at.present? && scheduled_at <= Time.now.utc + MINIMUM_OFFSET
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_total_limit
|
def validate_total_limit
|
||||||
|
|
|
@ -4,8 +4,6 @@ class PostStatusService < BaseService
|
||||||
include Redisable
|
include Redisable
|
||||||
include LanguagesHelper
|
include LanguagesHelper
|
||||||
|
|
||||||
MIN_SCHEDULE_OFFSET = 5.minutes.freeze
|
|
||||||
|
|
||||||
class UnexpectedMentionsError < StandardError
|
class UnexpectedMentionsError < StandardError
|
||||||
attr_reader :accounts
|
attr_reader :accounts
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Scheduler::ScheduledStatusesScheduler
|
||||||
end
|
end
|
||||||
|
|
||||||
def due_statuses
|
def due_statuses
|
||||||
ScheduledStatus.where(scheduled_at: ..Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET)
|
ScheduledStatus.where(scheduled_at: ..time_due_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish_scheduled_announcements!
|
def publish_scheduled_announcements!
|
||||||
|
@ -30,7 +30,7 @@ class Scheduler::ScheduledStatusesScheduler
|
||||||
end
|
end
|
||||||
|
|
||||||
def due_announcements
|
def due_announcements
|
||||||
Announcement.unpublished.where('scheduled_at IS NOT NULL AND scheduled_at <= ?', Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET)
|
Announcement.unpublished.where('scheduled_at IS NOT NULL AND scheduled_at <= ?', time_due_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unpublish_expired_announcements!
|
def unpublish_expired_announcements!
|
||||||
|
@ -40,4 +40,8 @@ class Scheduler::ScheduledStatusesScheduler
|
||||||
def expired_announcements
|
def expired_announcements
|
||||||
Announcement.published.where('ends_at IS NOT NULL AND ends_at <= ?', Time.now.utc)
|
Announcement.published.where('ends_at IS NOT NULL AND ends_at <= ?', Time.now.utc)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def time_due_at
|
||||||
|
Time.now.utc + ScheduledStatus::MINIMUM_OFFSET
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue