1
0

mention.rb 749 B

123456789101112131415161718192021222324252627282930313233343536
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: mentions
  5. #
  6. # id :bigint(8) not null, primary key
  7. # status_id :bigint(8)
  8. # created_at :datetime not null
  9. # updated_at :datetime not null
  10. # account_id :bigint(8)
  11. # silent :boolean default(FALSE), not null
  12. #
  13. class Mention < ApplicationRecord
  14. belongs_to :account, inverse_of: :mentions
  15. belongs_to :status
  16. has_one :notification, as: :activity, dependent: :destroy
  17. validates :account, uniqueness: { scope: :status }
  18. scope :active, -> { where(silent: false) }
  19. scope :silent, -> { where(silent: true) }
  20. delegate(
  21. :username,
  22. :acct,
  23. to: :account,
  24. prefix: true
  25. )
  26. def active?
  27. !silent?
  28. end
  29. end