fan out to group members

This commit is contained in:
2458773093 2019-08-09 15:11:11 +03:00
parent c8ce87e4f9
commit 213d5862ac
2 changed files with 18 additions and 0 deletions

View File

@ -28,4 +28,10 @@ module GroupInteractions
end end
end end
def accounts_for_local_distribution
accounts.local
.joins(:user)
.where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago)
end
end end

View File

@ -46,6 +46,16 @@ class FanOutOnWriteService < BaseService
end end
end end
def deliver_to_group_members(status)
Rails.logger.debug "Delivering status #{status.id} to group members #{status.group.id}"
status.group.accounts_for_local_distribution.select(:id).reorder(nil).find_in_batches do |members|
FeedInsertWorker.push_bulk(members) do |member|
[status.id, member.id, :home]
end
end
end
def deliver_to_lists(status) def deliver_to_lists(status)
Rails.logger.debug "Delivering status #{status.id} to lists" Rails.logger.debug "Delivering status #{status.id} to lists"
@ -62,6 +72,8 @@ class FanOutOnWriteService < BaseService
Rails.logger.debug "Delivering status #{status.id} to group" Rails.logger.debug "Delivering status #{status.id} to group"
Redis.current.publish("timeline:group:#{status.group_id}", @payload) Redis.current.publish("timeline:group:#{status.group_id}", @payload)
deliver_to_group_members(status)
end end
def deliver_to_mentioned_followers(status) def deliver_to_mentioned_followers(status)