mention.rb 748 B

1234567891011121314151617181920212223242526272829303132333435
  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