From b2df31118d63f10e3551151a895a296418d8610d Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Thu, 6 Nov 2025 22:08:39 -0500 Subject: [PATCH] simplify bulk updateUsers event to reduce code duplication --- packages/backend/src/core/CacheService.ts | 4 +++- packages/backend/src/core/GlobalEventService.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/CacheService.ts b/packages/backend/src/core/CacheService.ts index e144960ea3..f125784fe9 100644 --- a/packages/backend/src/core/CacheService.ts +++ b/packages/backend/src/core/CacheService.ts @@ -361,6 +361,7 @@ export class CacheService implements OnApplicationShutdown { this.internalEventService.on('userChangeDeletedState', this.onUserEvent); this.internalEventService.on('remoteUserUpdated', this.onUserEvent); this.internalEventService.on('localUserUpdated', this.onUserEvent); + this.internalEventService.on('userUpdated', this.onUserEvent); this.internalEventService.on('userTokenRegenerated', this.onTokenEvent); this.internalEventService.on('follow', this.onFollowEvent); this.internalEventService.on('unfollow', this.onFollowEvent); @@ -377,7 +378,7 @@ export class CacheService implements OnApplicationShutdown { } @bindThis - private async onUserEvent(body: InternalEventTypes[E], _: E, isLocal: boolean): Promise { + private async onUserEvent(body: InternalEventTypes[E], _: E, isLocal: boolean): Promise { const ids = 'ids' in body ? body.ids : [body.id]; if (ids.length === 0) return; @@ -686,6 +687,7 @@ export class CacheService implements OnApplicationShutdown { this.internalEventService.off('userChangeDeletedState', this.onUserEvent); this.internalEventService.off('remoteUserUpdated', this.onUserEvent); this.internalEventService.off('localUserUpdated', this.onUserEvent); + this.internalEventService.off('userUpdated', this.onUserEvent); this.internalEventService.off('userTokenRegenerated', this.onTokenEvent); this.internalEventService.off('follow', this.onFollowEvent); this.internalEventService.off('unfollow', this.onFollowEvent); diff --git a/packages/backend/src/core/GlobalEventService.ts b/packages/backend/src/core/GlobalEventService.ts index 167d226832..109e4c4946 100644 --- a/packages/backend/src/core/GlobalEventService.ts +++ b/packages/backend/src/core/GlobalEventService.ts @@ -238,6 +238,7 @@ export interface InternalEventTypes { remoteUserUpdated: { id: MiUser['id']; }; localUserUpdated: { id: MiUser['id']; }; usersUpdated: { ids: MiUser['id'][]; }; + userUpdated: { id: MiUser['id']; }; follow: { followerId: MiUser['id']; followeeId: MiUser['id']; }; unfollow: { followerId: MiUser['id']; followeeId: MiUser['id']; }; blockingCreated: { blockerId: MiUser['id']; blockeeId: MiUser['id']; };