about summary refs log tree commit diff
path: root/app/services/activitypub/fetch_replies_service.rb
blob: a398bbc79a2c692e3f47fc40d70fa9df7ba12338 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

class ActivityPub::FetchRepliesService < BaseService
  def call(parent_status, collection_or_uri, allow_synchronous_requests = true)
    @parent_status = parent_status
    @collection_or_uri = collection_or_uri
    @allow_synchronous_requests = allow_synchronous_requests

    items = fetch_collection_items
    return if items.blank?

    FetchReplyWorker.push_bulk(items)
    items
  end

  private

  def fetch_collection_items
    ActivityPub::FetchCollectionItemsService.new.call(
      @collection_or_uri, @parent_status&.account,
      page_limit: 1,
      item_limit: 20,
      allow_synchronous_requests: @allow_synchronous_requests
    )
  end
end