reduce log spam from ApDbResolverService.refetchPublicKeyForApId

This commit is contained in:
Hazelnoot 2025-05-22 09:40:30 -04:00
parent 2863f343f8
commit 53fbe87ff2

View file

@ -165,18 +165,23 @@ export class ApDbResolverService implements OnApplicationShutdown {
*/ */
@bindThis @bindThis
public async refetchPublicKeyForApId(user: MiRemoteUser): Promise<MiUserPublickey | null> { public async refetchPublicKeyForApId(user: MiRemoteUser): Promise<MiUserPublickey | null> {
this.apLoggerService.logger.debug('Re-fetching public key for user', { userId: user.id, uri: user.uri }); this.apLoggerService.logger.debug(`Updating public key for user ${user.id} (${user.uri})`);
const oldKey = await this.apPersonService.findPublicKeyByUserId(user.id);
await this.apPersonService.updatePerson(user.uri); await this.apPersonService.updatePerson(user.uri);
const newKey = await this.apPersonService.findPublicKeyByUserId(user.id);
const key = await this.apPersonService.findPublicKeyByUserId(user.id); if (newKey) {
if (oldKey && newKey.keyPem === oldKey.keyPem) {
if (key) { this.apLoggerService.logger.debug(`Public key is up-to-date for user ${user.id} (${user.uri})`);
this.apLoggerService.logger.info('Re-fetched public key for user', { userId: user.id, uri: user.uri }); } else {
this.apLoggerService.logger.info(`Updated public key for user ${user.id} (${user.uri})`);
}
} else { } else {
this.apLoggerService.logger.warn('Failed to re-fetch key for user', { userId: user.id, uri: user.uri }); this.apLoggerService.logger.warn(`Failed to update public key for user ${user.id} (${user.uri})`);
} }
return key; return newKey ?? oldKey;
} }
@bindThis @bindThis