about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-03-18 19:54:23 +0100
committerGitHub <noreply@github.com>2019-03-18 19:54:23 +0100
commitb9a998f201913dd1c89ddcb0c4c9e181eb73bfcf (patch)
tree2d5705651ce83b73900ff3e2ce61d8fef1c1b25d /app/models
parent6e3a4bcbc70bb33bfb0746cf3b2186ee9f4e6515 (diff)
parent841b920af5de8e3188111ca4dbea0c5105bde88c (diff)
Merge pull request #963 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models')
-rw-r--r--app/models/report.rb11
-rw-r--r--app/models/status.rb2
2 files changed, 12 insertions, 1 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
diff --git a/app/models/status.rb b/app/models/status.rb
index 440d7cc63..95f336820 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -473,8 +473,8 @@ class Status < ApplicationRecord
   end
 
   def set_visibility
+    self.visibility = reblog.visibility if reblog? && visibility.nil?
     self.visibility = (account.locked? ? :private : :public) if visibility.nil?
-    self.visibility = reblog.visibility if reblog?
     self.sensitive  = false if sensitive.nil?
   end