forked from cybrespace/mastodon
		
	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
This commit is contained in:
		
							parent
							
								
									777bcfc701
								
							
						
					
					
						commit
						8d44281677
					
				
					 2 changed files with 15 additions and 13 deletions
				
			
		| 
						 | 
					@ -78,10 +78,10 @@ class FeedManager
 | 
				
			||||||
  def filter_from_home?(status, receiver)
 | 
					  def filter_from_home?(status, receiver)
 | 
				
			||||||
    should_filter = false
 | 
					    should_filter = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if status.reply? && !status.thread.account.nil?                         # Filter out if it's a reply
 | 
					    if status.reply? && !status.in_reply_to_account_id.nil?                   # Filter out if it's a reply
 | 
				
			||||||
      should_filter   = !receiver.following?(status.thread.account)         # and I'm not following the person it's a reply to
 | 
					      should_filter   = !receiver.following?(status.in_reply_to_account)      # and I'm not following the person it's a reply to
 | 
				
			||||||
      should_filter &&= !(receiver.id == status.thread.account_id)          # and it's not a reply to me
 | 
					      should_filter &&= !(receiver.id == status.in_reply_to_account_id)       # and it's not a reply to me
 | 
				
			||||||
      should_filter &&= !(status.account_id == status.thread.account_id)    # and it's not a self-reply
 | 
					      should_filter &&= !(status.account_id == status.in_reply_to_account_id) # and it's not a self-reply
 | 
				
			||||||
    elsif status.reblog?                                                      # Filter out a reblog
 | 
					    elsif status.reblog?                                                      # Filter out a reblog
 | 
				
			||||||
      should_filter = receiver.blocking?(status.reblog.account)               # if I'm blocking the reblogged person
 | 
					      should_filter = receiver.blocking?(status.reblog.account)               # if I'm blocking the reblogged person
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					@ -98,8 +98,8 @@ class FeedManager
 | 
				
			||||||
    should_filter ||= (status.account.silenced? && !receiver.following?(status.account))    # of if the account is silenced and I'm not following them
 | 
					    should_filter ||= (status.account.silenced? && !receiver.following?(status.account))    # of if the account is silenced and I'm not following them
 | 
				
			||||||
    should_filter ||= (status.private_visibility? && !receiver.following?(status.account))  # or if the mentioned account is not permitted to see the private status
 | 
					    should_filter ||= (status.private_visibility? && !receiver.following?(status.account))  # or if the mentioned account is not permitted to see the private status
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if status.reply? && !status.thread.account.nil?                                         # or it's a reply
 | 
					    if status.reply? && !status.in_reply_to_account_id.nil?                                 # or it's a reply
 | 
				
			||||||
      should_filter ||= receiver.blocking?(status.thread.account)                           # to a user I blocked
 | 
					      should_filter ||= receiver.blocking?(status.in_reply_to_account)                      # to a user I blocked
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    should_filter
 | 
					    should_filter
 | 
				
			||||||
| 
						 | 
					@ -109,8 +109,8 @@ class FeedManager
 | 
				
			||||||
    should_filter   = receiver.blocking?(status.account)
 | 
					    should_filter   = receiver.blocking?(status.account)
 | 
				
			||||||
    should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account))
 | 
					    should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if status.reply? && !status.thread.account.nil?
 | 
					    if status.reply? && !status.in_reply_to_account_id.nil?
 | 
				
			||||||
      should_filter ||= receiver.blocking?(status.thread.account)
 | 
					      should_filter ||= receiver.blocking?(status.in_reply_to_account)
 | 
				
			||||||
    elsif status.reblog?
 | 
					    elsif status.reblog?
 | 
				
			||||||
      should_filter ||= receiver.blocking?(status.reblog.account)
 | 
					      should_filter ||= receiver.blocking?(status.reblog.account)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ class Status < ApplicationRecord
 | 
				
			||||||
  enum visibility: [:public, :unlisted, :private], _suffix: :visibility
 | 
					  enum visibility: [:public, :unlisted, :private], _suffix: :visibility
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  belongs_to :account, inverse_of: :statuses
 | 
					  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 :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
 | 
					  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
 | 
					  before_validation do
 | 
				
			||||||
    text.strip!
 | 
					    text.strip!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    self.reblog                 = reblog.reblog if reblog? && reblog.reblog?
 | 
					    self.reblog                 = reblog.reblog if reblog? && reblog.reblog?
 | 
				
			||||||
    self.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?
 | 
				
			||||||
    self.visibility             = (account.locked? ? :private : :public) if visibility.nil?
 | 
					    self.visibility             = (account.locked? ? :private : :public) if visibility.nil?
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue