Merge branch 'master' into glitch-soc/merge-upstream

This commit is contained in:
Thibaut Girka
2018-12-06 12:44:38 +01:00
16 changed files with 258 additions and 152 deletions

View File

@ -9,7 +9,9 @@ class BatchedRemoveStatusService < BaseService
# Remove statuses from home feeds
# Push delete events to streaming API for home feeds and public feeds
# @param [Status] statuses A preferably batched array of statuses
def call(statuses)
# @param [Hash] options
# @option [Boolean] :skip_side_effects
def call(statuses, **options)
statuses = Status.where(id: statuses.map(&:id)).includes(:account, :stream_entry).flat_map { |status| [status] + status.reblogs.includes(:account, :stream_entry).to_a }
@mentions = statuses.each_with_object({}) { |s, h| h[s.id] = s.active_mentions.includes(:account).to_a }
@ -26,6 +28,8 @@ class BatchedRemoveStatusService < BaseService
status.destroy
end
return if options[:skip_side_effects]
# Batch by source account
statuses.group_by(&:account_id).each_value do |account_statuses|
account = account_statuses.first.account