You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4 KiB

  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: reports
  5. #
  6. # id :integer not null, primary key
  7. # status_ids :integer default([]), not null, is an Array
  8. # comment :text default(""), not null
  9. # action_taken :boolean default(FALSE), not null
  10. # created_at :datetime not null
  11. # updated_at :datetime not null
  12. # account_id :integer not null
  13. # action_taken_by_account_id :integer
  14. # target_account_id :integer not null
  15. # assigned_account_id :integer
  16. #
  17. class Report < ApplicationRecord
  18. belongs_to :account
  19. belongs_to :target_account, class_name: 'Account'
  20. belongs_to :action_taken_by_account, class_name: 'Account', optional: true
  21. belongs_to :assigned_account, class_name: 'Account', optional: true
  22. has_many :notes, class_name: 'ReportNote', foreign_key: :report_id, inverse_of: :report, dependent: :destroy
  23. scope :unresolved, -> { where(action_taken: false) }
  24. scope :resolved, -> { where(action_taken: true) }
  25. validates :comment, length: { maximum: 1000 }
  26. def object_type
  27. :flag
  28. end
  29. def statuses
  30. Status.where(id: status_ids).includes(:account, :media_attachments, :mentions)
  31. end
  32. def media_attachments
  33. MediaAttachment.where(status_id: status_ids)
  34. end
  35. end