From 915eda7f88386557f77b5a0dc86d5fef20e7f3e1 Mon Sep 17 00:00:00 2001 From: unarist Date: Wed, 23 Aug 2017 03:00:49 +0900 Subject: [PATCH] Ignore empty response in ActivityPub::FetchRemoteStatusService (#4661) * 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 | 2 +- app/services/fetch_atom_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb index d8b3ddf18c..8355eb0556 100644 --- a/app/helpers/jsonld_helper.rb +++ b/app/helpers/jsonld_helper.rb @@ -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) diff --git a/app/services/fetch_atom_service.rb b/app/services/fetch_atom_service.rb index 3cf39e006c..afda50ae4f 100644 --- a/app/services/fetch_atom_service.rb +++ b/app/services/fetch_atom_service.rb @@ -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