From 5836bd85df4fe511f0ab766349eb4c9d1e1e5fdf Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Mon, 20 May 2024 19:25:50 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A4=87=E6=95=B0id=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=81=99=E3=82=8B`users/show`=E3=81=8C=E9=96=A2?= =?UTF-8?q?=E4=BF=82=E3=81=AA=E3=81=84=E3=83=A6=E3=83=BC=E3=82=B6=E3=82=92?= =?UTF-8?q?=E8=BF=94=E3=81=99=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82=E3=82=8B?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3=20(#13765)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 複数idを指定する`users/show`が関係ないユーザを返すことがある問題を修正 * test: fix misskey js test * chore: user/showがnullを返さないように * chore: pass lambda instead of pushVisibleUser --- CHANGELOG.md | 1 + packages/backend/src/misc/json-schema.ts | 2 +- .../backend/src/server/api/endpoints/users/show.ts | 4 +++- packages/frontend/src/components/MkPostForm.vue | 10 +++------- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0b98db96..a9944d4b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,7 @@ - Fix: AP Link等は添付ファイル扱いしないようになど (#13754) - Fix: FTTが有効かつsinceIdのみを指定した場合に帰って来るレスポンスが逆順である問題を修正 - Fix: `/i/notifications`に `includeTypes`か`excludeTypes`を指定しているとき、通知が存在するのに空配列を返すことがある問題を修正 +- Fix: 複数idを指定する`users/show`が関係ないユーザを返すことがある問題を修正 ## 2024.3.1 diff --git a/packages/backend/src/misc/json-schema.ts b/packages/backend/src/misc/json-schema.ts index a620d7c94..41e5bfe9e 100644 --- a/packages/backend/src/misc/json-schema.ts +++ b/packages/backend/src/misc/json-schema.ts @@ -228,7 +228,7 @@ export type SchemaTypeDef

= p['items']['allOf'] extends ReadonlyArray ? UnionToIntersection>>[] : never ) : - p['items'] extends NonNullable ? SchemaTypeDef[] : + p['items'] extends NonNullable ? SchemaType[] : any[] ) : p['anyOf'] extends ReadonlyArray ? UnionSchemaType & PartialIntersection> : diff --git a/packages/backend/src/server/api/endpoints/users/show.ts b/packages/backend/src/server/api/endpoints/users/show.ts index bd81989cb..26cfa921c 100644 --- a/packages/backend/src/server/api/endpoints/users/show.ts +++ b/packages/backend/src/server/api/endpoints/users/show.ts @@ -110,9 +110,11 @@ export default class extends Endpoint { // eslint- }); // リクエストされた通りに並べ替え + // 順番は保持されるけど数は減ってる可能性がある const _users: MiUser[] = []; for (const id of ps.userIds) { - _users.push(users.find(x => x.id === id)!); + const user = users.find(x => x.id === id); + if (user != null) _users.push(user); } return await Promise.all(_users.map(u => this.userEntityService.pack(u, me, { diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 7dbc12729..41d603e40 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -190,7 +190,7 @@ const localOnly = ref(props.initialLocalOnly ?? (defaultStore.state.rememberNote const visibility = ref(props.initialVisibility ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility)); const visibleUsers = ref([]); if (props.initialVisibleUsers) { - props.initialVisibleUsers.forEach(pushVisibleUser); + props.initialVisibleUsers.forEach(u => pushVisibleUser(u)); } const reactionAcceptance = ref(defaultStore.state.reactionAcceptance); const autocomplete = ref(null); @@ -336,7 +336,7 @@ if (props.reply && ['home', 'followers', 'specified'].includes(props.reply.visib misskeyApi('users/show', { userIds: props.reply.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.reply?.userId), }).then(users => { - users.forEach(pushVisibleUser); + users.forEach(u => pushVisibleUser(u)); }); } @@ -967,11 +967,7 @@ onMounted(() => { } if (draft.data.visibleUserIds) { misskeyApi('users/show', { userIds: draft.data.visibleUserIds }).then(users => { - for (let i = 0; i < users.length; i++) { - if (users[i].id === draft.data.visibleUserIds[i]) { - pushVisibleUser(users[i]); - } - } + users.forEach(u => pushVisibleUser(u)); }); } }