mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 18:45:41 +01:00
Add local delivery to the group's followers
This commit is contained in:
parent
c09a9b4235
commit
3237effc19
3 changed files with 18 additions and 2 deletions
|
@ -62,6 +62,19 @@ module AccountInteractions
|
|||
follow_mapping(AccountDomainBlock.where(account_id: account_id, domain: target_domains), :domain)
|
||||
end
|
||||
|
||||
def followers_for_local_distribution(accountIds)
|
||||
Account.where(id: Follow.where(target_account_id: accountIds).select(:account_id).distinct)
|
||||
.local
|
||||
.joins(:user)
|
||||
.where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago)
|
||||
end
|
||||
|
||||
def lists_for_local_distribution(accountIds)
|
||||
List.where(id: ListAccount.where(account_id: accountIds).select(:list_id).distinct)
|
||||
.joins(account: :user)
|
||||
.where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def follow_mapping(query, field)
|
||||
|
|
|
@ -21,6 +21,7 @@ class Mention < ApplicationRecord
|
|||
|
||||
scope :active, -> { where(silent: false) }
|
||||
scope :silent, -> { where(silent: true) }
|
||||
scope :groups, -> { joins(:account).where(accounts: { actor_type: 'Group' }) }
|
||||
|
||||
delegate(
|
||||
:username,
|
||||
|
|
|
@ -38,7 +38,8 @@ class FanOutOnWriteService < BaseService
|
|||
def deliver_to_followers(status)
|
||||
Rails.logger.debug "Delivering status #{status.id} to followers"
|
||||
|
||||
status.account.followers_for_local_distribution.select(:id).reorder(nil).find_in_batches do |followers|
|
||||
accountIds = [status.account_id] + status.mentions.groups.pluck(:account_id)
|
||||
Account.followers_for_local_distribution(accountIds).select(:id).reorder(nil).find_in_batches do |followers|
|
||||
FeedInsertWorker.push_bulk(followers) do |follower|
|
||||
[status.id, follower.id, :home]
|
||||
end
|
||||
|
@ -48,7 +49,8 @@ class FanOutOnWriteService < BaseService
|
|||
def deliver_to_lists(status)
|
||||
Rails.logger.debug "Delivering status #{status.id} to lists"
|
||||
|
||||
status.account.lists_for_local_distribution.select(:id).reorder(nil).find_in_batches do |lists|
|
||||
accountIds = [status.account_id] + status.mentions.groups.pluck(:account_id)
|
||||
Account.lists_for_local_distribution(accountIds).select(:id).reorder(nil).find_in_batches do |lists|
|
||||
FeedInsertWorker.push_bulk(lists) do |list|
|
||||
[status.id, list.id, :list]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue