about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-03-02 20:48:27 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-03-02 20:48:27 +0100
commit8743b1ea40425a83cc72834e823320439fd2fa02 (patch)
tree0bdfaca0357df1326bd3efb2e1a8319e719a2047 /app/services
parentd9e30efa5ecc87bc9be7b2e28baaf34bd01032f5 (diff)
parentc0c4b5718d8827fc59d5564c227e848547a2cb69 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/views/admin/trends/links/index.html.haml`:
  Not really a conflict, upstream change textually too close to a glitch-soc
  change (removed `javascript_pack_tag` to accomodate for glitch-soc's theming
  system).
  Ported upstream changes.
- `app/views/admin/trends/links/preview_card_providers/index.html.haml`:
  Not really a conflict, upstream change textually too close to a glitch-soc
  change (removed `javascript_pack_tag` to accomodate for glitch-soc's theming
  system).
  Ported upstream changes.
- `app/views/admin/trends/statuses/index.html.haml`:
  Not really a conflict, upstream change textually too close to a glitch-soc
  change (removed `javascript_pack_tag` to accomodate for glitch-soc's theming
  system).
  Ported upstream changes.
- `app/views/admin/trends/tags/index.html.haml`:
  Not really a conflict, upstream change textually too close to a glitch-soc
  change (removed `javascript_pack_tag` to accomodate for glitch-soc's theming
  system).
  Ported upstream changes.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/report_service.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/services/report_service.rb b/app/services/report_service.rb
index caf99ab6e..9d784c341 100644
--- a/app/services/report_service.rb
+++ b/app/services/report_service.rb
@@ -6,10 +6,10 @@ 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) || ''
-    @category       = options.delete(:category) || 'other'
-    @rule_ids       = options.delete(:rule_ids)
+    @status_ids     = options.delete(:status_ids).presence || []
+    @comment        = options.delete(:comment).presence || ''
+    @category       = options.delete(:category).presence || 'other'
+    @rule_ids       = options.delete(:rule_ids).presence
     @options        = options
 
     raise ActiveRecord::RecordNotFound if @target_account.suspended?
@@ -26,7 +26,7 @@ class ReportService < BaseService
   def create_report!
     @report = @source_account.reports.create!(
       target_account: @target_account,
-      status_ids: @status_ids,
+      status_ids: reported_status_ids,
       comment: @comment,
       uri: @options[:uri],
       forwarded: forward?,
@@ -56,6 +56,10 @@ class ReportService < BaseService
     !@target_account.local? && ActiveModel::Type::Boolean.new.cast(@options[:forward])
   end
 
+  def reported_status_ids
+    @target_account.statuses.with_discarded.find(Array(@status_ids)).pluck(:id)
+  end
+
   def payload
     Oj.dump(serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account))
   end