rename cacheService.getUsers to findUsers to match naming scheme

This commit is contained in:
Hazelnoot 2025-10-06 11:50:59 -04:00
parent 125c43299c
commit 6f0893a319
5 changed files with 10 additions and 10 deletions

View file

@ -583,6 +583,11 @@ export class CacheService implements OnApplicationShutdown {
return await this.userByIdCache.fetch(userId);
}
@bindThis
public async findUsersById(userIds: Iterable<string>): Promise<Map<string, MiUser>> {
return new Map(await this.userByIdCache.fetchMany(userIds));
}
@bindThis
public async findOptionalUserById(userId: MiUser['id']): Promise<MiUser | undefined> {
return await this.userByIdCache.fetchMaybe(userId);
@ -695,11 +700,6 @@ export class CacheService implements OnApplicationShutdown {
});
}
@bindThis
public async getUsers(userIds: Iterable<string>): Promise<Map<string, MiUser>> {
return new Map(await this.userByIdCache.fetchMany(userIds));
}
@bindThis
public async isFollowing(follower: string | { id: string }, followee: string | { id: string }): Promise<boolean> {
const followerId = typeof(follower) === 'string' ? follower : follower.id;

View file

@ -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)) {

View file

@ -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) => {

View file

@ -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<string, string | null> = {};
for (const [id, user] of users) {

View file

@ -97,7 +97,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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,