]> cat aescling's git repositories - mastodon.git/commitdiff
Ignore empty response in ActivityPub::FetchRemoteStatusService (#4661)
authorunarist <m.unarist@gmail.com>
Tue, 22 Aug 2017 18:00:49 +0000 (03:00 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 22 Aug 2017 18:00:49 +0000 (20:00 +0200)
* Ignore empty response in ActivityPub::FetchRemoteStatusService

This fixes `NoMethodError: undefined method `[]' for nil:NilClass` error.

* Check json.nil? in JsonLdHelper#supported_context?

app/helpers/jsonld_helper.rb
app/services/fetch_atom_service.rb

index d8b3ddf18c59076c186611dfe731a512b7f1fc99..8355eb055674786c8b03c765ccf19db38c6a6215 100644 (file)
@@ -14,7 +14,7 @@ module JsonLdHelper
   end
 
   def supported_context?(json)
-    equals_or_includes?(json['@context'], ActivityPub::TagManager::CONTEXT)
+    !json.nil? && equals_or_includes?(json['@context'], ActivityPub::TagManager::CONTEXT)
   end
 
   def fetch_resource(uri)
index 3cf39e006c1da16413a518c955ebc08746e9761c..afda50ae4f958c9ca706088b523fd1e4f3c4fd78 100644 (file)
@@ -82,7 +82,7 @@ class FetchAtomService < BaseService
 
   def supported_activity?(body)
     json = body_to_json(body)
-    return false if json.nil? || !supported_context?(json)
+    return false unless supported_context?(json)
     json['type'] == 'Person' ? json['inbox'].present? : true
   end
 end