about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-03-30 15:44:54 +0200
committerEugen Rochko <eugen@zeonfederated.com>2018-03-30 15:44:54 +0200
commite573bb0990ece4b1a521ccf8a4c7bec5972d3538 (patch)
treeb1c7c3b3d81aafb6bc256d74b02fbec1a54878f8 /app
parenta6c129ddbdaaa84bc631d85eb248fb5a9fa7eb96 (diff)
Fix compatibility with PeerTube (#6968)
* Support fetching objects of convertible types by URL (fixes #6924)

* Ignore invalid hashtags
Diffstat (limited to 'app')
-rw-r--r--app/lib/activitypub/activity/create.rb2
-rw-r--r--app/services/fetch_atom_service.rb6
-rw-r--r--app/services/resolve_url_service.rb2
3 files changed, 8 insertions, 2 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index afee8a268..45c0e91cb 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -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)
diff --git a/app/services/fetch_atom_service.rb b/app/services/fetch_atom_service.rb
index 62dea8298..87076cc07 100644
--- a/app/services/fetch_atom_service.rb
+++ b/app/services/fetch_atom_service.rb
@@ -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)
 
diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb
index 1f2b24524..9499dc286 100644
--- a/app/services/resolve_url_service.rb
+++ b/app/services/resolve_url_service.rb
@@ -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