2015-08-06 12:03:27 +00:00
|
|
|
class AbuseReport < ActiveRecord::Base
|
2016-10-06 21:17:11 +00:00
|
|
|
include CacheMarkdownField
|
|
|
|
|
|
|
|
cache_markdown_field :message, pipeline: :single_line
|
|
|
|
|
2015-09-29 16:08:55 +00:00
|
|
|
belongs_to :reporter, class_name: 'User'
|
2015-08-06 12:03:27 +00:00
|
|
|
belongs_to :user
|
|
|
|
|
|
|
|
validates :reporter, presence: true
|
|
|
|
validates :user, presence: true
|
|
|
|
validates :message, presence: true
|
2016-01-16 21:25:35 +00:00
|
|
|
validates :user_id, uniqueness: { message: 'has already been reported' }
|
2016-01-04 23:59:42 +00:00
|
|
|
|
2016-10-06 21:17:11 +00:00
|
|
|
# For CacheMarkdownField
|
|
|
|
alias_method :author, :reporter
|
|
|
|
|
2016-03-12 12:11:30 +00:00
|
|
|
def remove_user(deleted_by:)
|
2016-01-13 01:48:16 +00:00
|
|
|
user.block
|
2017-04-16 15:21:40 +00:00
|
|
|
DeleteUserWorker.perform_async(deleted_by.id, user.id, delete_solo_owned_groups: true, hard_delete: true)
|
2016-01-13 01:48:16 +00:00
|
|
|
end
|
|
|
|
|
2016-01-04 23:59:42 +00:00
|
|
|
def notify
|
|
|
|
return unless self.persisted?
|
|
|
|
|
|
|
|
AbuseReportMailer.notify(self.id).deliver_later
|
|
|
|
end
|
2015-08-06 12:03:27 +00:00
|
|
|
end
|