mirror of https://github.com/mastodon/mastodon
correct number of args to replies worker, recursive fetching is working
Signed-off-by: sneakers-the-rat <sneakers-the-rat@protonmail.com>
This commit is contained in:
parent
97a5aa501d
commit
f2f21c3233
|
@ -173,7 +173,7 @@ class Status < ApplicationRecord
|
|||
|
||||
REAL_TIME_WINDOW = 6.hours
|
||||
# debounce fetching all replies to minimize DoS
|
||||
FETCH_REPLIES_DEBOUNCE = 1.hour
|
||||
FETCH_REPLIES_DEBOUNCE = 30.minutes
|
||||
|
||||
def cache_key
|
||||
"v3:#{super}"
|
||||
|
|
|
@ -23,7 +23,7 @@ class ActivityPub::FetchRepliesService < BaseService
|
|||
@items = collection_items(collection_or_uri)
|
||||
return if @items.nil?
|
||||
|
||||
FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id }, @all_replies] }
|
||||
FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id, 'all_replies' => @all_replies }] }
|
||||
# Store last fetched all to debounce
|
||||
@status.update(fetched_replies_at: Time.now.utc) if fetch_all_replies?
|
||||
|
||||
|
|
|
@ -3,14 +3,17 @@
|
|||
class FetchReplyWorker
|
||||
include Sidekiq::Worker
|
||||
include ExponentialBackoff
|
||||
include JsonLdHelper
|
||||
|
||||
sidekiq_options queue: 'pull', retry: 3
|
||||
|
||||
def perform(child_url, options = {}, all_replies: false)
|
||||
def perform(child_url, options = {})
|
||||
all_replies = options.delete('all_replies')
|
||||
|
||||
status = FetchRemoteStatusService.new.call(child_url, **options.deep_symbolize_keys)
|
||||
|
||||
# asked to fetch replies recursively - do the second-level calls async
|
||||
if all_replies && status.should_fetch_replies?
|
||||
if all_replies && status
|
||||
json_status = fetch_resource(status.uri, true)
|
||||
|
||||
collection = json_status['replies']
|
||||
|
|
Loading…
Reference in New Issue