]> cat aescling's git repositories - mastodon.git/commitdiff
Fix AP serialization error when thread is missing (#4970)
authorunarist <m.unarist@gmail.com>
Sat, 16 Sep 2017 13:00:36 +0000 (22:00 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 16 Sep 2017 13:00:36 +0000 (15:00 +0200)
`Status#reply?` may returns true even if the thread is missing.
e.g. the replied status was deleted or couldn't be fetched.

Then it raises NoMethodError on various AP json serialization.

This issue won't happen on Atom serialization because it checks thread
existence using `StreamEntry#threaded?` instead.

app/serializers/activitypub/note_serializer.rb

index 7d53537b50a5a0619162f44c9ec6741c7b949c18..166214eee5256aa13eeba7117a683d6b2306f26d 100644 (file)
@@ -27,7 +27,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
   end
 
   def in_reply_to
-    return unless object.reply?
+    return unless object.reply? && !object.thread.nil?
 
     if object.thread.uri.nil? || object.thread.uri.start_with?('http')
       ActivityPub::TagManager.instance.uri_for(object.thread)
@@ -67,7 +67,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
   end
 
   def in_reply_to_atom_uri
-    return unless object.reply?
+    return unless object.reply? && !object.thread.nil?
 
     ::TagManager.instance.uri_for(object.thread)
   end