From 6331ed16e5953e3a006896c6df07b0f82cfd2350 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 9 Feb 2017 20:25:39 +0100 Subject: 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 --- app/models/status.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'app/models') 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 -- cgit