Change lists to be able to include accounts with pending follow requests (#19727)
This commit is contained in:
		@@ -272,6 +272,7 @@ module AccountInteractions
 | 
			
		||||
 | 
			
		||||
  def lists_for_local_distribution
 | 
			
		||||
    lists.joins(account: :user)
 | 
			
		||||
         .where.not(list_accounts: { follow_id: nil })
 | 
			
		||||
         .where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,8 @@ class FollowRequest < ApplicationRecord
 | 
			
		||||
  validates :languages, language: true
 | 
			
		||||
 | 
			
		||||
  def authorize!
 | 
			
		||||
    account.follow!(target_account, reblogs: show_reblogs, notify: notify, languages: languages, uri: uri, bypass_limit: true)
 | 
			
		||||
    follow = account.follow!(target_account, reblogs: show_reblogs, notify: notify, languages: languages, uri: uri, bypass_limit: true)
 | 
			
		||||
    ListAccount.where(follow_request: self).update_all(follow_request_id: nil, follow_id: follow.id) # rubocop:disable Rails/SkipsModelValidations
 | 
			
		||||
    MergeWorker.perform_async(target_account.id, account.id) if account.local?
 | 
			
		||||
    destroy!
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -4,16 +4,18 @@
 | 
			
		||||
#
 | 
			
		||||
# Table name: list_accounts
 | 
			
		||||
#
 | 
			
		||||
#  id         :bigint(8)        not null, primary key
 | 
			
		||||
#  list_id    :bigint(8)        not null
 | 
			
		||||
#  account_id :bigint(8)        not null
 | 
			
		||||
#  follow_id  :bigint(8)
 | 
			
		||||
#  id                :bigint(8)        not null, primary key
 | 
			
		||||
#  list_id           :bigint(8)        not null
 | 
			
		||||
#  account_id        :bigint(8)        not null
 | 
			
		||||
#  follow_id         :bigint(8)
 | 
			
		||||
#  follow_request_id :bigint(8)
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
class ListAccount < ApplicationRecord
 | 
			
		||||
  belongs_to :list
 | 
			
		||||
  belongs_to :account
 | 
			
		||||
  belongs_to :follow, optional: true
 | 
			
		||||
  belongs_to :follow_request, optional: true
 | 
			
		||||
 | 
			
		||||
  validates :account_id, uniqueness: { scope: :list_id }
 | 
			
		||||
 | 
			
		||||
@@ -22,6 +24,10 @@ class ListAccount < ApplicationRecord
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def set_follow
 | 
			
		||||
    self.follow = Follow.find_by!(account_id: list.account_id, target_account_id: account.id) unless list.account_id == account.id
 | 
			
		||||
    return if list.account_id == account.id
 | 
			
		||||
 | 
			
		||||
    self.follow = Follow.find_by!(account_id: list.account_id, target_account_id: account.id)
 | 
			
		||||
  rescue ActiveRecord::RecordNotFound
 | 
			
		||||
    self.follow_request = FollowRequest.find_by!(account_id: list.account_id, target_account_id: account.id)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user