Add Fetch All Replies Part 1: Backend (#32615)
Signed-off-by: sneakers-the-rat <sneakers-the-rat@protonmail.com> Co-authored-by: jonny <j@nny.fyi> Co-authored-by: Claire <claire.github-309c@sitedethib.com> Co-authored-by: Kouhai <66407198+kouhaidev@users.noreply.github.com>
This commit is contained in:
parent
2fe7172002
commit
46e13dd81c
18 changed files with 874 additions and 25 deletions
|
@ -13,7 +13,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService
|
|||
|
||||
@request_id = request_id || "#{Time.now.utc.to_i}-status-#{uri}"
|
||||
@json = if prefetched_body.nil?
|
||||
fetch_resource(uri, true, on_behalf_of)
|
||||
fetch_status(uri, true, on_behalf_of)
|
||||
else
|
||||
body_to_json(prefetched_body, compare_id: uri)
|
||||
end
|
||||
|
@ -80,4 +80,20 @@ class ActivityPub::FetchRemoteStatusService < BaseService
|
|||
def expected_object_type?
|
||||
equals_or_includes_any?(@json['type'], ActivityPub::Activity::Create::SUPPORTED_TYPES + ActivityPub::Activity::Create::CONVERTED_TYPES)
|
||||
end
|
||||
|
||||
def fetch_status(uri, id_is_known, on_behalf_of = nil)
|
||||
begin
|
||||
fetch_resource(uri, id_is_known, on_behalf_of, raise_on_error: true)
|
||||
rescue Mastodon::UnexpectedResponseError => e
|
||||
return unless e.response.code == 404
|
||||
|
||||
# If this is a 404 from a status from an account that has no local followers, delete it
|
||||
existing_status = Status.find_by(uri: uri)
|
||||
if !existing_status.nil? && existing_status.unsubscribed? && existing_status.distributable?
|
||||
Rails.logger.debug { "FetchRemoteStatusService - Got 404 for orphaned status with URI #{uri}, deleting" }
|
||||
Tombstone.find_or_create_by(uri: uri, account: existing_status.account)
|
||||
RemoveStatusService.new.call(existing_status, redraft: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue