From a6cd97ca9a4684e8621766e61d4171f0a1a2c3d8 Mon Sep 17 00:00:00 2001
From: syuilo <Syuilotan@yahoo.co.jp>
Date: Tue, 30 May 2023 17:27:47 +0900
Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E3=80=8C=E3=82=A2=E3=82=AF?=
 =?UTF-8?q?=E3=82=BB=E3=82=B9=E3=83=88=E3=83=BC=E3=82=AF=E3=83=B3=E3=81=AE?=
 =?UTF-8?q?=E7=AE=A1=E7=90=86=E3=80=8D=E7=94=BB=E9=9D=A2=E3=81=A7=E3=82=A2?=
 =?UTF-8?q?=E3=83=97=E3=83=AA=E3=81=AE=E6=83=85=E5=A0=B1=E3=81=8C=E8=A1=A8?=
 =?UTF-8?q?=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C?=
 =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix #10920
---
 CHANGELOG.md                                             | 5 +++--
 packages/backend/src/server/api/endpoints/auth/accept.ts | 3 ---
 packages/backend/src/server/api/endpoints/i/apps.ts      | 5 +++--
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 36bc63b0af..a61051e32b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,8 +34,9 @@
 - アカウントの初期設定ウィザードにあとでボタンを追加
 - Fix: URLプレビューで情報が取得できなかった際の挙動を修正
 - Fix: Safari、Firefoxでの新規登録時、パスワードマネージャーにメールアドレスが登録されていた挙動を修正
-- fix:ロールタイムラインが無効でも投稿が流れてしまう問題の修正
-- fix:ロールタイムラインにて全ての投稿が流れてしまう問題の修正
+- Fix: ロールタイムラインが無効でも投稿が流れてしまう問題の修正
+- Fix: ロールタイムラインにて全ての投稿が流れてしまう問題の修正
+- Fix: 「アクセストークンの管理」画面でアプリの情報が表示されない問題の修正
 
 ### Server
 - bullをbull-mqにアップグレードし、ジョブキューのパフォーマンスを改善
diff --git a/packages/backend/src/server/api/endpoints/auth/accept.ts b/packages/backend/src/server/api/endpoints/auth/accept.ts
index cb2e661bfb..05842460cf 100644
--- a/packages/backend/src/server/api/endpoints/auth/accept.ts
+++ b/packages/backend/src/server/api/endpoints/auth/accept.ts
@@ -55,7 +55,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
 				throw new ApiError(meta.errors.noSuchSession);
 			}
 
-			// Generate access token
 			const accessToken = secureRndstr(32, true);
 
 			// Fetch exist access token
@@ -65,7 +64,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
 			});
 
 			if (exist == null) {
-				// Lookup app
 				const app = await this.appsRepository.findOneByOrFail({ id: session.appId });
 
 				// Generate Hash
@@ -75,7 +73,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
 
 				const now = new Date();
 
-				// Insert access token doc
 				await this.accessTokensRepository.insert({
 					id: this.idService.genId(),
 					createdAt: now,
diff --git a/packages/backend/src/server/api/endpoints/i/apps.ts b/packages/backend/src/server/api/endpoints/i/apps.ts
index 3361e5a4d3..48fb03a8af 100644
--- a/packages/backend/src/server/api/endpoints/i/apps.ts
+++ b/packages/backend/src/server/api/endpoints/i/apps.ts
@@ -26,7 +26,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
 	) {
 		super(meta, paramDef, async (ps, me) => {
 			const query = this.accessTokensRepository.createQueryBuilder('token')
-				.where('token.userId = :userId', { userId: me.id });
+				.where('token.userId = :userId', { userId: me.id })
+				.leftJoinAndSelect('token.app', 'app');
 
 			switch (ps.sort) {
 				case '+createdAt': query.orderBy('token.createdAt', 'DESC'); break;
@@ -40,7 +41,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
 
 			return await Promise.all(tokens.map(token => ({
 				id: token.id,
-				name: token.name,
+				name: token.name ?? token.app?.name,
 				createdAt: token.createdAt,
 				lastUsedAt: token.lastUsedAt,
 				permission: token.permission,
-- 
GitLab