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.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index ec492293f..946958758 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -79,6 +79,7 @@ class Status < ApplicationRecord
   has_one :stream_entry, as: :activity, inverse_of: :status
   has_one :status_stat, inverse_of: :status
   has_one :poll, inverse_of: :status, dependent: :destroy
+  has_one :destructing_status, inverse_of: :status, dependent: :destroy
 
   validates :uri, uniqueness: true, presence: true, unless: :local?
   validates :text, presence: true, unless: -> { with_media? || reblog? }
@@ -266,6 +267,18 @@ class Status < ApplicationRecord
     @chat_tags = tags.only_chat
   end
 
+  def delete_after
+    destructing_status&.delete_after
+  end
+
+  def delete_after=(value)
+    if destructing_status.nil?
+      DestructingStatus.create!(status_id: id, delete_after: Time.now.utc + value)
+    else
+      destructing_status.delete_after = Time.now.utc + value
+    end
+  end
+
   def mark_for_mass_destruction!
     @marked_for_mass_destruction = true
   end