Update AP transformers, fixes #1637

This commit is contained in:
Daniel Supernault 2019-10-07 02:36:29 -06:00
parent d14ad094c2
commit ef77de4e05
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 12 additions and 2 deletions

View file

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

View file

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