about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-12-31 14:35:08 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-12-31 14:36:25 +0100
commit8d442816774e2f7974a02bf262ff9e6fdfeab4f4 (patch)
treeaafddfde01fe2d015400cf9c9ec663693a3d82b4 /app/models
parent777bcfc7016d4f4354af2d337dee113c6e2ad8a9 (diff)
Set in_reply_to_account on statuses to non-self value when possible, thus
resolving the confusion from self-chain replies ultimately linking to a
non-self status. Adjust filters
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 1720d754a..bc595c93b 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -8,6 +8,7 @@ class Status < ApplicationRecord
   enum visibility: [:public, :unlisted, :private], _suffix: :visibility
 
   belongs_to :account, inverse_of: :statuses
+  belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account'
 
   belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies
   belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, touch: true
@@ -170,8 +171,9 @@ class Status < ApplicationRecord
 
   before_validation do
     text.strip!
-    self.reblog = reblog.reblog if reblog? && reblog.reblog?
-    self.in_reply_to_account_id = thread.account_id if 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.visibility             = (account.locked? ? :private : :public) if visibility.nil?
   end