Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSRでユーザープロフィールが表示されない #15051

Closed
1 task done
eternal-flame-AD opened this issue Nov 24, 2024 · 3 comments
Closed
1 task done

SSRでユーザープロフィールが表示されない #15051

eternal-flame-AD opened this issue Nov 24, 2024 · 3 comments
Labels
⚠️bug? This might be a bug

Comments

@eternal-flame-AD
Copy link
Contributor

eternal-flame-AD commented Nov 24, 2024

💡 Summary

SSRでユーザープロフィールが表示されない

Patch diff https://forge.yumechi.jp/yume/yumechi-no-kuni/commit/c2029ed2715a4106823be9cabbe6d151ea1944bb
diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts
index 54c608ac9e..7c7ec24e05 100644
--- a/packages/backend/src/server/web/ClientServerService.ts
+++ b/packages/backend/src/server/web/ClientServerService.ts
@@ -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;
diff --git a/packages/frontend/src/pages/user/home.vue b/packages/frontend/src/pages/user/home.vue
index 2794db2821..65a36c42e9 100644
--- a/packages/frontend/src/pages/user/home.vue
+++ b/packages/frontend/src/pages/user/home.vue
@@ -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>

🥰 Expected Behavior

プロフィールを表示できる

🤬 Actual Behavior

できない

📝 Steps to Reproduce

プライバシータブまたは新しいブラウザプロフィールで(前提条件ではなく、完全な再現性のためだけです。プライバシータブなしでも再現できる):

@[email protected]

Console: TypeError: e.value.roles is undefined

Fixed:

@[email protected]

💻 Frontend Environment

* Model and OS of the device(s): Linux + Android
* Browser: Librewolf 132 + Firefox 132 + User Report
* Server URL: misskey.gg + nya.one + hollow.raccoon.quest && [yumechi.jp (already patched)]
* Misskey: 2024.11.0

🛰 Backend Environment (for server admin)

Various derivatives of 2024.11.0

Do you want to address this bug yourself?

  • Yes, I will patch the bug myself and send a pull request
@eternal-flame-AD eternal-flame-AD added the ⚠️bug? This might be a bug label Nov 24, 2024
@samunohito
Copy link
Member

#15032
#15033

ユーザーのプロフィール画面については上記のissue/prで処置済みです。
diffを見るとページのルートにも手が加えられていますが、ページもSSRに失敗するということでしょうか…?

@eternal-flame-AD
Copy link
Contributor Author

@samunohito

申し訳ありません!クローズされた問題を確認すべきでした。

リモート ページをSSRしないのは単なる防御プログラミングであり、これに関して既知の問題は確認されていません。

@samunohito
Copy link
Member

起票ありがとうございました、重複として処理させて頂きますね。

Duplicate of #15032

@samunohito samunohito closed this as not planned Won't fix, can't repro, duplicate, stale Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️bug? This might be a bug
Projects
None yet
Development

No branches or pull requests

2 participants