You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
894 B

  1. # frozen_string_literal: true
  2. class ActivityPub::Activity::Flag < ActivityPub::Activity
  3. def perform
  4. target_accounts = object_uris.map { |uri| account_from_uri(uri) }.compact.select(&:local?)
  5. target_statuses_by_account = object_uris.map { |uri| status_from_uri(uri) }.compact.select(&:local?).group_by(&:account_id)
  6. target_accounts.each do |target_account|
  7. next if Report.where(account: @account, target_account: target_account).exists?
  8. target_statuses = target_statuses_by_account[target_account.id]
  9. ReportService.new.call(
  10. @account,
  11. target_account,
  12. status_ids: target_statuses.nil? ? [] : target_statuses.map(&:id),
  13. comment: @json['content'] || ''
  14. )
  15. end
  16. end
  17. def object_uris
  18. @object_uris ||= Array(@object.is_a?(Array) ? @object.map { |item| value_or_id(item) } : value_or_id(@object))
  19. end
  20. end