summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/CacheService.ts
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2024-02-16 14:30:53 +0900
committerGitHub <noreply@github.com>2024-02-16 14:30:53 +0900
commitcfa573a3a1cffa9d24aa790d551d13e6a40bd958 (patch)
treee12a82512e51b8eb414b87a3b31384e32e9deb07 /packages/backend/src/core/CacheService.ts
parentfix(backend): add missing schemas and fix incorrect schemas (#13295) (diff)
downloadsharkey-cfa573a3a1cffa9d24aa790d551d13e6a40bd958.tar.gz
sharkey-cfa573a3a1cffa9d24aa790d551d13e6a40bd958.tar.bz2
sharkey-cfa573a3a1cffa9d24aa790d551d13e6a40bd958.zip
リモートユーザーが復活してもキャッシュにより該当ユーザーのActivityが受け入れられないのを修正 Fix #13273 (#13275)
* リモートユーザーが復活してもキャッシュにより該当ユーザーのActivityが受け入れられないのを修正 Fix #13273 * CHAGELOG * Use Redis event --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Diffstat (limited to 'packages/backend/src/core/CacheService.ts')
-rw-r--r--packages/backend/src/core/CacheService.ts28
1 files changed, 19 insertions, 9 deletions
diff --git a/packages/backend/src/core/CacheService.ts b/packages/backend/src/core/CacheService.ts
index ef3abec191..78bb4f70e9 100644
--- a/packages/backend/src/core/CacheService.ts
+++ b/packages/backend/src/core/CacheService.ts
@@ -85,6 +85,7 @@ export class CacheService implements OnApplicationShutdown {
this.uriPersonCache = new MemoryKVCache<MiUser | null, string | null>(Infinity, {
toMapConverter: user => {
if (user === null) return null;
+ if (user.isDeleted) return null;
userByIdCache.set(user.id, user);
return user.id;
@@ -160,16 +161,25 @@ export class CacheService implements OnApplicationShutdown {
switch (type) {
case 'userChangeSuspendedState':
case 'remoteUserUpdated': {
- const user = await this.usersRepository.findOneByOrFail({ id: body.id });
- this.userByIdCache.set(user.id, user);
- for (const [k, v] of this.uriPersonCache.cache.entries()) {
- if (v.value === user.id) {
- this.uriPersonCache.set(k, user);
+ const user = await this.usersRepository.findOneBy({ id: body.id });
+ if (user == null) {
+ this.userByIdCache.delete(body.id);
+ for (const [k, v] of this.uriPersonCache.cache.entries()) {
+ if (v.value === body.id) {
+ this.uriPersonCache.delete(k);
+ }
+ }
+ } else {
+ this.userByIdCache.set(user.id, user);
+ for (const [k, v] of this.uriPersonCache.cache.entries()) {
+ if (v.value === user.id) {
+ this.uriPersonCache.set(k, user);
+ }
+ }
+ if (this.userEntityService.isLocalUser(user)) {
+ this.localUserByNativeTokenCache.set(user.token!, user);
+ this.localUserByIdCache.set(user.id, user);
}
- }
- if (this.userEntityService.isLocalUser(user)) {
- this.localUserByNativeTokenCache.set(user.token!, user);
- this.localUserByIdCache.set(user.id, user);
}
break;
}