mirror of https://github.com/tootsuite/mastodon
committing all ugly with a bunch of logger calls in the middle but we are almost there baby
Signed-off-by: sneakers-the-rat <sneakers-the-rat@protonmail.com>
parent
dd5a5acd52
commit
78751251df
|
@ -2,6 +2,7 @@
|
|||
|
||||
class Api::V1::StatusesController < Api::BaseController
|
||||
include Authorization
|
||||
include JsonLdHelper
|
||||
|
||||
before_action -> { authorize_if_got_token! :read, :'read:statuses' }, except: [:create, :update, :destroy]
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:statuses' }, only: [:create, :update, :destroy]
|
||||
|
@ -48,15 +49,24 @@ class Api::V1::StatusesController < Api::BaseController
|
|||
descendants_limit = DESCENDANTS_LIMIT
|
||||
descendants_depth_limit = DESCENDANTS_DEPTH_LIMIT
|
||||
else
|
||||
collection = @status['replies']
|
||||
unless @status.local?
|
||||
json_status = fetch_resource(@status.uri, true, @current_account)
|
||||
|
||||
unless collection.nil? && @status.local?
|
||||
ActivityPub::FetchRepliesService.new.call(
|
||||
value_or_id(@status),
|
||||
value_or_id(collection),
|
||||
allow_synchronous_requests: true,
|
||||
all_replies: true
|
||||
)
|
||||
logger.warn "json status"
|
||||
logger.warn json_status
|
||||
# rescue this whole block on failure, don't want to fail the whole context request if we can't do this
|
||||
collection = json_status['replies']
|
||||
logger.warn "replies uri"
|
||||
logger.warn collection
|
||||
|
||||
unless collection.nil?
|
||||
ActivityPub::FetchRepliesService.new.call(
|
||||
@status,
|
||||
collection,
|
||||
allow_synchronous_requests: true,
|
||||
all_replies: true
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@ class ActivityPub::FetchRepliesService < BaseService
|
|||
@allow_synchronous_requests = allow_synchronous_requests
|
||||
|
||||
@items = collection_items(collection_or_uri)
|
||||
logger = Logger.new(STDOUT)
|
||||
logger.warn 'collection items'
|
||||
logger.warn @items
|
||||
return if @items.nil?
|
||||
|
||||
FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id }] }
|
||||
|
@ -25,12 +28,20 @@ class ActivityPub::FetchRepliesService < BaseService
|
|||
private
|
||||
|
||||
def collection_items(collection_or_uri)
|
||||
logger = Logger.new(STDOUT)
|
||||
collection = fetch_collection(collection_or_uri)
|
||||
logger.warn 'first collection'
|
||||
logger.warn collection
|
||||
return unless collection.is_a?(Hash)
|
||||
|
||||
collection = fetch_collection(collection['first']) if collection['first'].present?
|
||||
logger.warn 'second collection'
|
||||
logger.warn collection
|
||||
return unless collection.is_a?(Hash)
|
||||
|
||||
# Need to do another "next" here. see https://neuromatch.social/users/jonny/statuses/112401738180959195/replies for example
|
||||
# then we are home free (stopping for tonight tho.)
|
||||
|
||||
case collection['type']
|
||||
when 'Collection', 'CollectionPage'
|
||||
as_array(collection['items'])
|
||||
|
|
Loading…
Reference in New Issue