about summary refs log tree commit diff
path: root/app/models/report.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-03-18 18:03:27 +0100
committerThibaut Girka <thib@sitedethib.com>2019-03-18 18:03:27 +0100
commit291012ec0c08f5323b2102eb4d2dc8714ddce4d9 (patch)
tree09e7a5fef106da1b6ebdc53ac0df62cafc159520 /app/models/report.rb
parent6e3a4bcbc70bb33bfb0746cf3b2186ee9f4e6515 (diff)
parentf85b66eb8cc9513822d0ece3928b12aa789bb410 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/controllers/accounts_controller.rb
- app/controllers/follower_accounts_controller.rb
- app/controllers/statuses_controller.rb

All conflicts caused by the additional `use_pack` used for glitch-soc's theming
system.
Diffstat (limited to 'app/models/report.rb')
-rw-r--r--app/models/report.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/report.rb b/app/models/report.rb
index 2804020f5..86c303798 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -13,6 +13,7 @@
 #  action_taken_by_account_id :bigint(8)
 #  target_account_id          :bigint(8)        not null
 #  assigned_account_id        :bigint(8)
+#  uri                        :string
 #
 
 class Report < ApplicationRecord
@@ -28,6 +29,12 @@ class Report < ApplicationRecord
 
   validates :comment, length: { maximum: 1000 }
 
+  def local?
+    false # Force uri_for to use uri attribute
+  end
+
+  before_validation :set_uri, only: :create
+
   def object_type
     :flag
   end
@@ -89,4 +96,8 @@ class Report < ApplicationRecord
 
     Admin::ActionLog.from("(#{sql}) AS admin_action_logs")
   end
+
+  def set_uri
+    self.uri = ActivityPub::TagManager.instance.generate_uri_for(self) if uri.nil? && account.local?
+  end
 end