Browse Source

Fix compatibility with PeerTube (#6968)

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

* Ignore invalid hashtags
pull/4/head
ThibG 6 years ago
committed by Eugen Rochko
parent
commit
e573bb0990
3 changed files with 8 additions and 2 deletions
  1. +2
    -0
      app/lib/activitypub/activity/create.rb
  2. +5
    -1
      app/services/fetch_atom_service.rb
  3. +1
    -1
      app/services/resolve_url_service.rb

+ 2
- 0
app/lib/activitypub/activity/create.rb View File

@ -79,6 +79,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
hashtag = Tag.where(name: hashtag).first_or_initialize(name: hashtag)
status.tags << hashtag
rescue ActiveRecord::RecordInvalid
nil
end
def process_mention(tag, status)

+ 5
- 1
app/services/fetch_atom_service.rb View File

@ -44,7 +44,7 @@ class FetchAtomService < BaseService
json = body_to_json(body)
if supported_context?(json) && json['type'] == 'Person' && json['inbox'].present?
[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]
else
@unsupported_activity = true
@ -61,6 +61,10 @@ class FetchAtomService < BaseService
end
end
def expected_type?(json)
(ActivityPub::Activity::Create::SUPPORTED_TYPES + ActivityPub::Activity::Create::CONVERTED_TYPES).include? json['type']
end
def process_html(response)
page = Nokogiri::HTML(response.body_with_limit)

+ 1
- 1
app/services/resolve_url_service.rb View File

@ -19,7 +19,7 @@ class ResolveURLService < BaseService
case type
when 'Person'
FetchRemoteAccountService.new.call(atom_url, body, protocol)
when 'Note'
when 'Note', 'Article', 'Image', 'Video'
FetchRemoteStatusService.new.call(atom_url, body, protocol)
end
end

Loading…
Cancel
Save