From 977f06ec56e34f822976dcf9939488d9bafd764f Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sun, 1 Nov 2020 15:23:54 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20error=20when=20webmention=20author=20can?= =?UTF-8?q?=E2=80=99t=20be=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/WebMention.php | 5 +++++ resources/views/notes/show.blade.php | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Models/WebMention.php b/app/Models/WebMention.php index 48fe5596..8e175bcb 100644 --- a/app/Models/WebMention.php +++ b/app/Models/WebMention.php @@ -90,6 +90,11 @@ class WebMention extends Model { $authorship = new Authorship(); $hCard = $authorship->findAuthor(json_decode($this->mf2, true)); + + if ($hCard === false) { + return []; + } + if ( array_key_exists('properties', $hCard) && array_key_exists('photo', $hCard['properties']) diff --git a/resources/views/notes/show.blade.php b/resources/views/notes/show.blade.php index 8f40c096..459cf5d5 100644 --- a/resources/views/notes/show.blade.php +++ b/resources/views/notes/show.blade.php @@ -9,9 +9,17 @@ return ($webmention->type == 'in-reply-to'); }) as $reply)
- - @if (array_key_exists('photo', $reply['author']['properties']))@endif {{ $reply['author']['properties']['name'][0] }} - said at {{ $reply['published'] }} + @if ($reply['author']) + + @if (array_key_exists('photo', $reply['author']['properties'])) + + @endif + {{ $reply['author']['properties']['name'][0] }} + + @else + Unknown author + @endif + said at {{ $reply['published'] }}
{!! $reply['reply'] !!}