Repair: copy legacy joinDate into new user's created_at when creating users from legacy wallz

This commit is contained in:
2026-03-22 09:13:39 +01:00
parent e8b5edf5d2
commit 2608be7420
80 changed files with 3991 additions and 723 deletions

View File

@@ -1,6 +1,7 @@
<?php
namespace App\Http\Resources;
use App\Services\ContentSanitizer;
use App\Services\ThumbnailPresenter;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\DB;
@@ -100,6 +101,7 @@ class ArtworkResource extends JsonResource
'slug' => (string) $this->slug,
'title' => $decode($this->title),
'description' => $decode($this->description),
'description_html' => $this->renderDescriptionHtml(),
'dimensions' => [
'width' => (int) ($this->width ?? 0),
'height' => (int) ($this->height ?? 0),
@@ -123,6 +125,8 @@ class ArtworkResource extends JsonResource
'username' => (string) ($this->user?->username ?? ''),
'profile_url' => $this->user?->username ? '/@' . $this->user->username : null,
'avatar_url' => $this->user?->profile?->avatar_url,
'level' => (int) ($this->user?->level ?? 1),
'rank' => (string) ($this->user?->rank ?? 'Newbie'),
'followers_count' => $followerCount,
],
'viewer' => [
@@ -168,4 +172,27 @@ class ArtworkResource extends JsonResource
])->values(),
];
}
private function renderDescriptionHtml(): string
{
$rawDescription = (string) ($this->description ?? '');
if (trim($rawDescription) === '') {
return '';
}
if (! $this->authorCanPublishLinks()) {
return nl2br(e(ContentSanitizer::stripToPlain($rawDescription)));
}
return ContentSanitizer::render($rawDescription);
}
private function authorCanPublishLinks(): bool
{
$level = (int) ($this->user?->level ?? 1);
$rank = strtolower((string) ($this->user?->rank ?? 'Newbie'));
return $level > 1 && $rank !== 'newbie';
}
}