diff --git a/packages/backend/src/core/CacheService.ts b/packages/backend/src/core/CacheService.ts index e7b4157da8..6f9fb6eeea 100644 --- a/packages/backend/src/core/CacheService.ts +++ b/packages/backend/src/core/CacheService.ts @@ -583,6 +583,11 @@ export class CacheService implements OnApplicationShutdown { return await this.userByIdCache.fetch(userId); } + @bindThis + public async findUsersById(userIds: Iterable): Promise> { + return new Map(await this.userByIdCache.fetchMany(userIds)); + } + @bindThis public async findOptionalUserById(userId: MiUser['id']): Promise { return await this.userByIdCache.fetchMaybe(userId); @@ -695,11 +700,6 @@ export class CacheService implements OnApplicationShutdown { }); } - @bindThis - public async getUsers(userIds: Iterable): Promise> { - return new Map(await this.userByIdCache.fetchMany(userIds)); - } - @bindThis public async isFollowing(follower: string | { id: string }, followee: string | { id: string }): Promise { const followerId = typeof(follower) === 'string' ? follower : follower.id; diff --git a/packages/backend/src/core/FanoutTimelineEndpointService.ts b/packages/backend/src/core/FanoutTimelineEndpointService.ts index ddb0ddb7d2..6657a04dc9 100644 --- a/packages/backend/src/core/FanoutTimelineEndpointService.ts +++ b/packages/backend/src/core/FanoutTimelineEndpointService.ts @@ -276,7 +276,7 @@ export class FanoutTimelineEndpointService { // Fetch everything and populate users const [users, instances] = await Promise.all([ - this.cacheService.getUsers(usersToFetch), + this.cacheService.findUsersById(usersToFetch), this.federatedInstanceService.federatedInstanceCache.fetchMany(instancesToFetch).then(i => new Map(i)), ]); for (const [id, user] of Array.from(users)) { diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index 34fdffb430..e30475b0f6 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -238,7 +238,7 @@ export class NotificationEntityService implements OnModuleInit { if (notification.type === 'reaction:grouped') userIds.push(...notification.reactions.map(x => x.userId)); if (notification.type === 'renote:grouped') userIds.push(...notification.userIds); } - const users = await this.cacheService.getUsers(userIds); + const users = await this.cacheService.findUsersById(userIds); const packedUsersArray = await this.userEntityService.packMany(Array.from(users.values()), me); const packedUsers = new Map(packedUsersArray.map(p => [p.id, p])); @@ -343,7 +343,7 @@ export class NotificationEntityService implements OnModuleInit { ] = await Promise.all([ this.cacheService.userMutingsCache.fetch(meId), this.cacheService.userMutingsCache.fetch(meId), - this.cacheService.getUsers(notifierIds), + this.cacheService.findUsersById(notifierIds), ]); const filteredNotifications = ((await Promise.all(notifications.map(async (notification) => { diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index be27440ba9..f080cf1feb 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -289,7 +289,7 @@ export class UserEntityService implements OnModuleInit { this.cacheService.userBlockingCache.fetch(me), this.cacheService.userMutingsCache.fetch(me), this.cacheService.renoteMutingsCache.fetch(me), - this.cacheService.getUsers(targets) + this.cacheService.findUsersById(targets) .then(users => { const record: Record = {}; for (const [id, user] of users) { diff --git a/packages/backend/src/server/api/endpoints/admin/cw-note.ts b/packages/backend/src/server/api/endpoints/admin/cw-note.ts index 92071abaf1..17773c5b81 100644 --- a/packages/backend/src/server/api/endpoints/admin/cw-note.ts +++ b/packages/backend/src/server/api/endpoints/admin/cw-note.ts @@ -97,7 +97,7 @@ export default class extends Endpoint { // eslint- reactionAcceptance: note.reactionAcceptance, visibility: note.visibility, visibleUsers: note.visibleUserIds.length > 0 - ? this.cacheService.getUsers(note.visibleUserIds).then(us => Array.from(us.values())) : null, + ? this.cacheService.findUsersById(note.visibleUserIds).then(us => Array.from(us.values())) : null, channel: note.channel ?? (note.channelId ? this.channelsRepository.findOneByOrFail({ id: note.channelId }) : null), apMentions: undefined, apHashtags: undefined,