optimizations

This commit is contained in:
2026-03-28 19:15:39 +01:00
parent 0b25d9570a
commit cab4fbd83e
509 changed files with 1016804 additions and 1605 deletions

View File

@@ -4,6 +4,7 @@
use App\Support\ForumPostContent;
use App\Support\AvatarUrl;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
$filesBaseUrl = rtrim((string) config('cdn.files_url', ''), '/');
@@ -26,6 +27,8 @@
'name' => $user->name,
'avatar_url' => AvatarUrl::forUser((int) $user->id, $user->profile?->avatar_hash ?? null),
'role' => $user->role ?? 'member',
'level' => (int) ($user->level ?? 1),
'rank' => (string) ($user->rank ?? 'Newbie'),
] : null,
'attachments' => collect($post->attachments ?? [])->map(fn ($a) => [
'id' => $a->id,
@@ -40,6 +43,15 @@
$serializedOp = isset($opPost) && $opPost ? $serializePost($opPost) : null;
$serializedPosts = collect($posts->items())->map($serializePost)->values()->all();
$threadDescription = null;
$threadDescriptionSource = (string) ($serializedOp['rendered_content'] ?? $serializedOp['content'] ?? '');
if ($threadDescriptionSource !== '') {
$threadDescriptionSource = html_entity_decode($threadDescriptionSource, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$threadDescriptionSource = html_entity_decode($threadDescriptionSource, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$threadDescription = trim((string) preg_replace('/\s+/u', ' ', strip_tags($threadDescriptionSource)));
$threadDescription = Str::limit($threadDescription, 220);
}
$paginationData = [
'current_page' => $posts->currentPage(),
@@ -57,6 +69,7 @@
'id' => $thread->id,
'title' => $thread->title,
'slug' => $thread->slug,
'description'=> $threadDescription,
'views' => (int) ($thread->views ?? 0),
'is_pinned' => (bool) $thread->is_pinned,
'is_locked' => (bool) $thread->is_locked,