0
0
Fork 0

Add category and rule_ids params to POST /api/v1/reports (#17492)

This commit is contained in:
Eugen Rochko 2022-02-10 00:10:16 +01:00 committed by GitHub
parent 5533fa28b6
commit 2f8159baad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 3 deletions

View file

@ -8,13 +8,15 @@ class ReportService < BaseService
@target_account = target_account
@status_ids = options.delete(:status_ids) || []
@comment = options.delete(:comment) || ''
@category = options.delete(:category) || 'other'
@rule_ids = options.delete(:rule_ids)
@options = options
raise ActiveRecord::RecordNotFound if @target_account.suspended?
create_report!
notify_staff!
forward_to_origin! if !@target_account.local? && ActiveModel::Type::Boolean.new.cast(@options[:forward])
forward_to_origin! if forward?
@report
end
@ -27,7 +29,9 @@ class ReportService < BaseService
status_ids: @status_ids,
comment: @comment,
uri: @options[:uri],
forwarded: ActiveModel::Type::Boolean.new.cast(@options[:forward])
forwarded: forward?,
category: @category,
rule_ids: @rule_ids
)
end
@ -48,6 +52,10 @@ class ReportService < BaseService
)
end
def forward?
!@target_account.local? && ActiveModel::Type::Boolean.new.cast(@options[:forward])
end
def payload
Oj.dump(serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account))
end