about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-02-09 20:25:39 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-02-09 20:25:39 +0100
commit6331ed16e5953e3a006896c6df07b0f82cfd2350 (patch)
treeb1b03e90ccb2feddc65aaf689808658381118228 /app/models
parentc424df5192f346dba5332a4b3a2de43b2f028e0c (diff)
Fix #614 - extra reply-boolean on statuses to account for cases when replied-to
status is not in the system at time of distribution; fix #607 - reset privacy
settings to defaults when cancelling replies
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 6ef0b2bdd..c6690c312 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -39,6 +39,10 @@ class Status < ApplicationRecord
 
   cache_associated :account, :application, :media_attachments, :tags, :stream_entry, mentions: :account, reblog: [:account, :application, :stream_entry, :tags, :media_attachments, mentions: :account], thread: :account
 
+  def reply?
+    super || !in_reply_to_id.nil?
+  end
+
   def local?
     uri.nil?
   end
@@ -47,10 +51,6 @@ class Status < ApplicationRecord
     !reblog_of_id.nil?
   end
 
-  def reply?
-    !in_reply_to_id.nil?
-  end
-
   def verb
     reblog? ? :share : :post
   end
@@ -105,7 +105,7 @@ class Status < ApplicationRecord
     def as_public_timeline(account = nil, local_only = false)
       query = joins('LEFT OUTER JOIN accounts ON statuses.account_id = accounts.id')
               .where(visibility: :public)
-              .where('(statuses.in_reply_to_id IS NULL OR statuses.in_reply_to_account_id = statuses.account_id)')
+              .where('(statuses.reply = false OR statuses.in_reply_to_account_id = statuses.account_id)')
               .where('statuses.reblog_of_id IS NULL')
 
       query = query.where('accounts.domain IS NULL') if local_only
@@ -176,8 +176,9 @@ class Status < ApplicationRecord
     text.strip!
     spoiler_text&.strip!
 
+    self.reply                  = !(in_reply_to_id.nil? && thread.nil?) unless attributes[:reply]
     self.reblog                 = reblog.reblog if reblog? && reblog.reblog?
-    self.in_reply_to_account_id = (thread.account_id == account_id && thread.reply? ? thread.in_reply_to_account_id : thread.account_id) if reply?
+    self.in_reply_to_account_id = (thread.account_id == account_id && thread.reply? ? thread.in_reply_to_account_id : thread.account_id) if reply? && !thread.nil?
     self.visibility             = (account.locked? ? :private : :public) if visibility.nil?
   end