Browse Source

Update AP transformers, fixes #1637

Daniel Supernault 5 years ago
parent
commit
2c16db187b

+ 17 - 0
app/Transformer/ActivityPub/Verb/CreateNote.php

@@ -22,6 +22,23 @@ class CreateNote extends Fractal\TransformerAbstract
 				'name' => $name
 			];
 		})->toArray();
+
+		if($status->in_reply_to_id != null) {
+			$parent = $status->parent()->profile;
+			if($parent) {
+				$webfinger = $parent->emailUrl();
+				$name = Str::startsWith($webfinger, '@') ? 
+					$webfinger :
+					'@' . $webfinger;
+				$reply = [
+					'type' => 'Mention',
+					'href' => $parent->permalink(),
+					'name' => $name
+				];
+				$mentions = array_merge($reply, $mentions);
+			}
+		}
+
 		$hashtags = $status->hashtags->map(function ($hashtag) {
 			return [
 				'type' => 'Hashtag',

+ 17 - 0
app/Transformer/ActivityPub/Verb/Note.php

@@ -22,6 +22,23 @@ class Note extends Fractal\TransformerAbstract
 				'name' => $name
 			];
 		})->toArray();
+
+		if($status->in_reply_to_id != null) {
+			$parent = $status->parent()->profile;
+			if($parent) {
+				$webfinger = $parent->emailUrl();
+				$name = Str::startsWith($webfinger, '@') ? 
+					$webfinger :
+					'@' . $webfinger;
+				$reply = [
+					'type' => 'Mention',
+					'href' => $parent->permalink(),
+					'name' => $name
+				];
+				$mentions = array_merge($reply, $mentions);
+			}
+		}
+		
 		$hashtags = $status->hashtags->map(function ($hashtag) {
 			return [
 				'type' => 'Hashtag',