浏览代码

Update AP transformers, fixes #1637

Daniel Supernault 5 年之前
父节点
当前提交
ef77de4e05
共有 2 个文件被更改,包括 12 次插入2 次删除
  1. 6 1
      app/Transformer/ActivityPub/Verb/CreateNote.php
  2. 6 1
      app/Transformer/ActivityPub/Verb/Note.php

+ 6 - 1
app/Transformer/ActivityPub/Verb/CreateNote.php

@@ -4,6 +4,7 @@ namespace App\Transformer\ActivityPub\Verb;
 
 use App\Status;
 use League\Fractal;
+use Illuminate\Support\Str;
 
 class CreateNote extends Fractal\TransformerAbstract
 {
@@ -11,10 +12,14 @@ class CreateNote extends Fractal\TransformerAbstract
 	{
 
 		$mentions = $status->mentions->map(function ($mention) {
+			$webfinger = $mention->emailUrl();
+			$name = Str::startsWith($webfinger, '@') ? 
+				$webfinger :
+				'@' . $webfinger;
 			return [
 				'type' => 'Mention',
 				'href' => $mention->permalink(),
-				'name' => $mention->emailUrl()
+				'name' => $name
 			];
 		})->toArray();
 		$hashtags = $status->hashtags->map(function ($hashtag) {

+ 6 - 1
app/Transformer/ActivityPub/Verb/Note.php

@@ -4,6 +4,7 @@ namespace App\Transformer\ActivityPub\Verb;
 
 use App\Status;
 use League\Fractal;
+use Illuminate\Support\Str;
 
 class Note extends Fractal\TransformerAbstract
 {
@@ -11,10 +12,14 @@ class Note extends Fractal\TransformerAbstract
 	{
 
 		$mentions = $status->mentions->map(function ($mention) {
+			$webfinger = $mention->emailUrl();
+			$name = Str::startsWith($webfinger, '@') ? 
+				$webfinger :
+				'@' . $webfinger;
 			return [
 				'type' => 'Mention',
 				'href' => $mention->permalink(),
-				'name' => $mention->emailUrl()
+				'name' => $name
 			];
 		})->toArray();
 		$hashtags = $status->hashtags->map(function ($hashtag) {