Browse Source

Update ActivityPub helpers, fix comment threading in statusFetch() method

Daniel Supernault 4 years ago
parent
commit
26b9c1401c
2 changed files with 13 additions and 3 deletions
  1. 12 2
      app/Http/Controllers/SearchController.php
  2. 1 1
      app/Util/ActivityPub/Helpers.php

+ 12 - 2
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()
 			]];
 		}

+ 1 - 1
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 {