diff --git a/app/Transformer/ActivityPub/Verb/CreateNote.php b/app/Transformer/ActivityPub/Verb/CreateNote.php index 83f7e6020..e565ad9e8 100644 --- a/app/Transformer/ActivityPub/Verb/CreateNote.php +++ b/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) { diff --git a/app/Transformer/ActivityPub/Verb/Note.php b/app/Transformer/ActivityPub/Verb/Note.php index d27875967..98c2dec10 100644 --- a/app/Transformer/ActivityPub/Verb/Note.php +++ b/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) {