Skip to content
Extraits de code Groupes Projets
Valider e573bb09 rédigé par ThibG's avatar ThibG Validation de Eugen Rochko
Parcourir les fichiers

Fix compatibility with PeerTube (#6968)

* Support fetching objects of convertible types by URL (fixes #6924)

* Ignore invalid hashtags
parent a6c129dd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -79,6 +79,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity ...@@ -79,6 +79,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
hashtag = Tag.where(name: hashtag).first_or_initialize(name: hashtag) hashtag = Tag.where(name: hashtag).first_or_initialize(name: hashtag)
status.tags << hashtag status.tags << hashtag
rescue ActiveRecord::RecordInvalid
nil
end end
def process_mention(tag, status) def process_mention(tag, status)
......
...@@ -44,7 +44,7 @@ class FetchAtomService < BaseService ...@@ -44,7 +44,7 @@ class FetchAtomService < BaseService
json = body_to_json(body) json = body_to_json(body)
if supported_context?(json) && json['type'] == 'Person' && json['inbox'].present? if supported_context?(json) && json['type'] == 'Person' && json['inbox'].present?
[json['id'], { prefetched_body: body, id: true }, :activitypub] [json['id'], { prefetched_body: body, id: true }, :activitypub]
elsif supported_context?(json) && json['type'] == 'Note' elsif supported_context?(json) && expected_type?(json)
[json['id'], { prefetched_body: body, id: true }, :activitypub] [json['id'], { prefetched_body: body, id: true }, :activitypub]
else else
@unsupported_activity = true @unsupported_activity = true
...@@ -61,6 +61,10 @@ class FetchAtomService < BaseService ...@@ -61,6 +61,10 @@ class FetchAtomService < BaseService
end end
end end
def expected_type?(json)
(ActivityPub::Activity::Create::SUPPORTED_TYPES + ActivityPub::Activity::Create::CONVERTED_TYPES).include? json['type']
end
def process_html(response) def process_html(response)
page = Nokogiri::HTML(response.body_with_limit) page = Nokogiri::HTML(response.body_with_limit)
......
...@@ -19,7 +19,7 @@ class ResolveURLService < BaseService ...@@ -19,7 +19,7 @@ class ResolveURLService < BaseService
case type case type
when 'Person' when 'Person'
FetchRemoteAccountService.new.call(atom_url, body, protocol) FetchRemoteAccountService.new.call(atom_url, body, protocol)
when 'Note' when 'Note', 'Article', 'Image', 'Video'
FetchRemoteStatusService.new.call(atom_url, body, protocol) FetchRemoteStatusService.new.call(atom_url, body, protocol)
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter