2015-09-06 10:48:48 -04:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: abuse_reports
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# reporter_id :integer
|
|
|
|
# user_id :integer
|
|
|
|
# message :text
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
#
|
|
|
|
|
2015-08-06 08:03:27 -04:00
|
|
|
class AbuseReport < ActiveRecord::Base
|
2015-09-29 12:08:55 -04:00
|
|
|
belongs_to :reporter, class_name: 'User'
|
2015-08-06 08:03:27 -04:00
|
|
|
belongs_to :user
|
|
|
|
|
|
|
|
validates :reporter, presence: true
|
|
|
|
validates :user, presence: true
|
|
|
|
validates :message, presence: true
|
2016-01-16 16:25:35 -05:00
|
|
|
validates :user_id, uniqueness: { message: 'has already been reported' }
|
2016-01-04 18:59:42 -05:00
|
|
|
|
2016-03-12 07:11:30 -05:00
|
|
|
def remove_user(deleted_by:)
|
2016-01-12 20:48:16 -05:00
|
|
|
user.block
|
2016-03-12 07:11:30 -05:00
|
|
|
DeleteUserWorker.perform_async(deleted_by.id, user.id, delete_solo_owned_groups: true)
|
2016-01-12 20:48:16 -05:00
|
|
|
end
|
|
|
|
|
2016-01-04 18:59:42 -05:00
|
|
|
def notify
|
|
|
|
return unless self.persisted?
|
|
|
|
|
|
|
|
AbuseReportMailer.notify(self.id).deliver_later
|
|
|
|
end
|
2015-08-06 08:03:27 -04:00
|
|
|
end
|