BigW Consortium Gitlab

abuse_report.rb 541 Bytes
Newer Older
1
class AbuseReport < ActiveRecord::Base
2
  belongs_to :reporter, class_name: 'User'
3 4 5 6 7
  belongs_to :user

  validates :reporter, presence: true
  validates :user, presence: true
  validates :message, presence: true
8
  validates :user_id, uniqueness: { message: 'has already been reported' }
9

10
  def remove_user(deleted_by:)
11
    user.block
12
    DeleteUserWorker.perform_async(deleted_by.id, user.id, delete_solo_owned_groups: true)
13 14
  end

15 16 17 18 19
  def notify
    return unless self.persisted?

    AbuseReportMailer.notify(self.id).deliver_later
  end
20
end