about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-03-17 15:34:56 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-03-17 15:34:56 +0100
commita20354a20b9dffada0e8d6170ebc2ff13c79baea (patch)
tree74d1a47399b0cbd24187562b1a864ae5e984979c /app/models
parent5e38ef87a7b8bac59ffa0d98464086ab8a60a2e1 (diff)
Set and store report URIs (#10303)
Fixes #10271
Diffstat (limited to 'app/models')
-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