From 26b9c1401ceedbcfe1bae21e802129f333dcaf0b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 8 Jul 2021 21:30:59 -0600 Subject: [PATCH] Update ActivityPub helpers, fix comment threading in statusFetch() method --- app/Http/Controllers/SearchController.php | 14 ++++++++++++-- app/Util/ActivityPub/Helpers.php | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index c273e95d..cbf21518 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -321,13 +321,18 @@ class SearchController extends Controller if(Status::whereUri($tag)->whereLocal(false)->exists()) { $item = Status::whereUri($tag)->first(); + $media = $item->firstMedia(); + $url = null; + if($media) { + $url = $media->remote_url; + } $this->tokens['posts'] = [[ 'count' => 0, 'url' => "/i/web/post/_/$item->profile_id/$item->id", 'type' => 'status', 'username' => $item->profile->username, 'caption' => $item->rendered ?? $item->caption, - 'thumb' => $item->firstMedia()->remote_url, + 'thumb' => $url, 'timestamp' => $item->created_at->diffForHumans() ]]; } @@ -336,13 +341,18 @@ class SearchController extends Controller if(isset($remote['type']) && $remote['type'] == 'Note') { $item = Helpers::statusFetch($tag); + $media = $item->firstMedia(); + $url = null; + if($media) { + $url = $media->remote_url; + } $this->tokens['posts'] = [[ 'count' => 0, 'url' => "/i/web/post/_/$item->profile_id/$item->id", 'type' => 'status', 'username' => $item->profile->username, 'caption' => $item->rendered ?? $item->caption, - 'thumb' => $item->firstMedia()->remote_url, + 'thumb' => $url, 'timestamp' => $item->created_at->diffForHumans() ]]; } diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index 58876bc2..48d37615 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -351,7 +351,7 @@ class Helpers { } $profile = self::profileFirstOrNew($activity['object']['attributedTo']); - if(isset($activity['object']['inReplyTo']) && !empty($activity['object']['inReplyTo']) && $replyTo == true) { + if(isset($activity['object']['inReplyTo']) && !empty($activity['object']['inReplyTo']) || $replyTo == true) { $reply_to = self::statusFirstOrFetch($activity['object']['inReplyTo'], false); $reply_to = optional($reply_to)->id; } else {