2019-07-02 08:10:25 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ReportService < BaseService
|
|
|
|
def call(source_account, target_account, options = {})
|
|
|
|
@source_account = source_account
|
|
|
|
@target_account = target_account
|
|
|
|
@status_ids = options.delete(:status_ids) || []
|
|
|
|
@comment = options.delete(:comment) || ''
|
|
|
|
@options = options
|
|
|
|
|
2021-02-11 19:30:37 +00:00
|
|
|
return nil if @target_account.suspended_at != nil
|
|
|
|
|
2019-07-02 08:10:25 +01:00
|
|
|
create_report!
|
|
|
|
|
|
|
|
@report
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_report!
|
|
|
|
@report = @source_account.reports.create!(
|
|
|
|
target_account: @target_account,
|
|
|
|
status_ids: @status_ids,
|
|
|
|
comment: @comment,
|
|
|
|
uri: @options[:uri]
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|