about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 9067f44df..9c061bf85 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -376,6 +376,7 @@ class Status < ApplicationRecord
   after_destroy_commit :decrement_counter_caches
 
   after_create_commit :store_uri, if: :local?
+  after_create_commit :store_url, if: :local?
   after_create_commit :update_statistics, if: :local?
 
   around_create Mastodon::Snowflake::Callbacks
@@ -392,6 +393,7 @@ class Status < ApplicationRecord
 
   after_save :set_domain_permissions, if: :local?
   after_save :set_semiprivate, if: :local?
+  after_save :set_conversation_root
 
   class << self
     def selectable_visibilities
@@ -676,6 +678,10 @@ class Status < ApplicationRecord
     update_column(:uri, ActivityPub::TagManager.instance.uri_for(self)) if uri.nil?
   end
 
+  def store_url
+    update_column(:url, ActivityPub::TagManager.instance.url_for(self)) if url.nil?
+  end
+
   def prepare_contents
     text&.strip!
     spoiler_text&.strip!
@@ -717,6 +723,10 @@ class Status < ApplicationRecord
     end
   end
 
+  def set_conversation_root
+    conversation.update!(root: uri, account_id: account_id, public: distributable?) if !reply && conversation.root.blank?
+  end
+
   def carried_over_reply_to_account_id
     if thread.account_id == account_id && thread.reply?
       thread.in_reply_to_account_id