merge: Slightly optimize i/update-remote-user endpoint by fetching from cache (!1185)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1185 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
41be003d79
2 changed files with 29 additions and 2 deletions
|
|
@ -9,7 +9,7 @@ import { In, IsNull } from 'typeorm';
|
|||
import type { BlockingsRepository, FollowingsRepository, MutingsRepository, RenoteMutingsRepository, MiUserProfile, UserProfilesRepository, UsersRepository, MiNote, MiFollowing, NoteThreadMutingsRepository } from '@/models/_.js';
|
||||
import { MemoryKVCache, RedisKVCache } from '@/misc/cache.js';
|
||||
import { QuantumKVCache } from '@/misc/QuantumKVCache.js';
|
||||
import type { MiLocalUser, MiUser } from '@/models/User.js';
|
||||
import type { MiLocalUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
|
@ -387,6 +387,17 @@ export class CacheService implements OnApplicationShutdown {
|
|||
}) ?? null;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async findRemoteUserById(userId: MiUser['id']): Promise<MiRemoteUser | null> {
|
||||
const user = await this.findUserById(userId);
|
||||
|
||||
if (user.host == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return user as MiRemoteUser;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async getFollowStats(userId: MiUser['id']): Promise<FollowStats> {
|
||||
return await this.userFollowStatsCache.fetch(userId, async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue