minor fixes

This commit is contained in:
2026-04-09 08:50:36 +02:00
parent 23d363a50c
commit a2457f4e49
75 changed files with 3848 additions and 387 deletions

View File

@@ -61,6 +61,22 @@ class ArtworkListResource extends JsonResource
$decode = static fn (?string $v): string => html_entity_decode((string) ($v ?? ''), ENT_QUOTES | ENT_HTML5, 'UTF-8');
$group = $this->relationLoaded('group') ? $this->group : null;
$user = $this->relationLoaded('user') ? $this->user : null;
$isGroupPublisher = $group !== null;
$publisher = ($group || $user)
? [
'type' => $isGroupPublisher ? 'group' : 'user',
'id' => (int) ($isGroupPublisher ? $group?->id : $user?->id),
'name' => $decode($isGroupPublisher ? $group?->name : $user?->name),
'username' => $isGroupPublisher ? '' : (string) ($user?->username ?? ''),
'avatar_url' => $isGroupPublisher ? $group?->avatarUrl() : $user?->profile?->avatar_url,
'profile_url' => $isGroupPublisher
? $group?->publicUrl()
: (! empty($user?->username) ? '/@' . $user->username : null),
]
: null;
return [
'id' => $artId,
'slug' => $slugVal,
@@ -71,12 +87,12 @@ class ArtworkListResource extends JsonResource
'height' => $get('height'),
],
'thumbnail_url' => $this->when(! empty($hash) && ! empty($thumbExt), fn() => ThumbnailService::fromHash($hash, $thumbExt, 'md')),
'author' => $this->whenLoaded('user', function () use ($decode) {
return [
'name' => $decode($this->user->name ?? null),
'avatar_url' => $this->user?->profile?->avatar_url,
];
}),
'author' => $publisher,
'publisher' => $publisher,
'author_name' => $publisher['name'] ?? '',
'avatar_url' => $publisher['avatar_url'] ?? null,
'profile_url' => $publisher['profile_url'] ?? null,
'published_as_type' => $publisher['type'] ?? null,
'category' => $primaryCategory ? [
'slug' => $primaryCategory->slug ?? null,
'name' => $decode($primaryCategory->name ?? null),