Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
凍結されたユーザーが含まれている場合一部の機能が誤動作する不具合を修正 (MisskeyIO#161)
Browse files Browse the repository at this point in the history
z-6561
  • Loading branch information
u1-liquid authored and nafu-at committed Sep 4, 2023
1 parent 821aa8d commit b02a553
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
13 changes: 13 additions & 0 deletions packages/backend/src/core/entities/NoteReactionEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,17 @@ export class NoteReactionEntityService implements OnModuleInit {
} : {}),
};
}

@bindThis
public async packMany(
reactions: (MiNoteReaction['id'] | MiNoteReaction)[],
me: { id: MiUser['id'] } | null | undefined,
options?: {
withNote: boolean;
},
) : Promise<Packed<'NoteReaction'>[]> {
return (await Promise.allSettled(reactions.map(x => this.pack(x, me, options))))
.filter(result => result.status === 'fulfilled')
.map(result => (result as PromiseFulfilledResult<Packed<'NoteReaction'>>).value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
folderId: ps.folderId ?? IsNull(),
});

return await Promise.all(files.map(file => this.driveFileEntityService.pack(file, me, { self: true })));
return await this.driveFileEntityService.packMany(files, me, { self: true });
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
relations: ['user', 'note'],
});

return await Promise.all(reactions.map(reaction => this.noteReactionEntityService.pack(reaction, me)));
return await this.noteReactionEntityService.packMany(reactions, me);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.limit(ps.limit)
.getMany();

return await Promise.all(reactions.map(reaction => this.noteReactionEntityService.pack(reaction, me, { withNote: true })));
return await this.noteReactionEntityService.packMany(reactions, me, { withNote: true });
});
}
}
7 changes: 4 additions & 3 deletions packages/backend/src/server/api/endpoints/users/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
// リクエストされた通りに並べ替え
const _users: MiUser[] = [];
for (const id of ps.userIds) {
_users.push(users.find(x => x.id === id)!);
const user = users.find((u) => u.id === id);
if (user) _users.push(user);
}

return await Promise.all(_users.map(u => this.userEntityService.pack(u, me, {
return await this.userEntityService.packMany(_users, me, {
detail: true,
})));
});
} else {
// Lookup user
if (typeof ps.host === 'string' && typeof ps.username === 'string') {
Expand Down

0 comments on commit b02a553

Please sign in to comment.