<commit_before># frozen_string_literal: true

class Pubsubhubbub::DistributionWorker
  include Sidekiq::Worker

  sidekiq_options queue: 'push'

  def perform(stream_entry_id)
    stream_entry = StreamEntry.find(stream_entry_id)

    # Most hidden stream entries should not be PuSHed,
    # but statuses need to be distributed to trusted
    # followers even when they are hidden
    return if stream_entry.hidden? && stream_entry.activity_type != 'Status'

    account  = stream_entry.account
    renderer = AccountsController.renderer.new(method: 'get', http_host: Rails.configuration.x.local_domain, https: Rails.configuration.x.use_https)
    payload  = renderer.render(:show, assigns: { account: account, entries: [stream_entry] }, formats: [:atom])
    domains  = account.followers_domains

    Subscription.where(account: account).active.select('id, callback_url').find_each do |subscription|
      next unless domains.include?(Addressable::URI.parse(subscription.callback_url).host)
      Pubsubhubbub::DeliveryWorker.perform_async(subscription.id, payload)
    end
  rescue ActiveRecord::RecordNotFound
    true
  end
end<commit_msg>Take out private toot distribution out of PuSH again<commit_after># frozen_string_literal: true

class Pubsubhubbub::DistributionWorker
  include Sidekiq::Worker

  sidekiq_options queue: 'push'

  def perform(stream_entry_id)
    stream_entry = StreamEntry.find(stream_entry_id)

    return if stream_entry.hidden?

    account  = stream_entry.account
    renderer = AccountsController.renderer.new(method: 'get', http_host: Rails.configuration.x.local_domain, https: Rails.configuration.x.use_https)
    payload  = renderer.render(:show, assigns: { account: account, entries: [stream_entry] }, formats: [:atom])

    Subscription.where(account: account).active.select('id').find_each do |subscription|
      Pubsubhubbub::DeliveryWorker.perform_async(subscription.id, payload)
    end
  rescue ActiveRecord::RecordNotFound
    true
  end
end
{'fraction_non_alphanumeric': 0.09420654911838791, 'fraction_numerical': 0.0, 'mean_word_length': 5.0920245398773005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7479253', 'n_tokens_mistral': 589, 'n_tokens_neox': 579, 'n_words': 131}