Fix(frontend): SSRでユーザープロフィールが表示されない問題を修正

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-11-24 05:56:19 -06:00
parent 82c80a53a6
commit c2029ed271
No known key found for this signature in database
2 changed files with 11 additions and 4 deletions

View file

@ -638,7 +638,9 @@ export class ClientServerService {
reply.header('X-Robots-Tag', 'noai');
}
const _user = await this.userEntityService.pack(user);
const _user = await this.userEntityService.pack(user, null, {
schema: host ? 'UserLite' : 'UserDetailedNotMe' // リモートユーザーの場合は詳細情報を返さない
});
return await reply.view('user', {
user, profile, me,
@ -712,9 +714,14 @@ export class ClientServerService {
// Page
fastify.get<{ Params: { user: string; page: string; } }>('/@:user/pages/:page', async (request, reply) => {
const { username, host } = Acct.parse(request.params.user);
if (host) {
return await renderBase(reply); // リモートユーザーのページはSSRしない
}
const user = await this.usersRepository.findOneBy({
usernameLower: username.toLowerCase(),
host: host ?? IsNull(),
host: IsNull(),
});
if (user == null) return;

View file

@ -53,7 +53,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div><MkSparkle><Mfm :plain="true" :text="user.followedMessage" :author="user"/></MkSparkle></div>
</MkFukidashi>
</div>
<div v-if="user.roles.length > 0" class="roles">
<div v-if="user.roles && user.roles.length > 0" class="roles">
<span v-for="role in user.roles" :key="role.id" v-tooltip="role.description" class="role" :style="{ '--color': role.color }">
<MkA v-adaptive-bg :to="`/roles/${role.id}`">
<img v-if="role.iconUrl" style="height: 1.3em; vertical-align: -22%;" :src="role.iconUrl"/>
@ -96,7 +96,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<dt class="name"><i class="ti ti-cake ti-fw"></i> {{ i18n.ts.birthday }}</dt>
<dd class="value">{{ user.birthday.replace('-', '/').replace('-', '/') }} ({{ i18n.tsx.yearsOld({ age }) }})</dd>
</dl>
<dl class="field">
<dl v-if="user.createdAt" class="field">
<dt class="name"><i class="ti ti-calendar ti-fw"></i> {{ i18n.ts.registeredDate }}</dt>
<dd class="value">{{ dateString(user.createdAt) }} (<MkTime :time="user.createdAt"/>)</dd>
</dl>