about summary refs log tree commit diff
path: root/app/models/defederating_status.rb
blob: e6af6c1b6c2e27c2f58669993034caa080e0a68a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# == Schema Information
#
# Table name: defederating_statuses
#
#  id               :bigint(8)        not null, primary key
#  status_id        :bigint(8)
#  defederate_after :datetime
#

class DefederatingStatus < ApplicationRecord
  belongs_to :status, inverse_of: :defederating_status

  validate :validate_future_date
  validates :status_id, uniqueness: true

  private

  def validate_future_date
    errors.add(:defederate_after, I18n.t('defederating_statuses.too_soon')) if defederate_after.present? && defederate_after < Time.now.utc + PostStatusService::MIN_DESTRUCT_OFFSET
  end
end