とりあえずtryで囲っておく

This commit is contained in:
tamaina 2024-03-10 16:17:09 +00:00
parent e2b574a97c
commit 76487de5ed
1 changed files with 19 additions and 13 deletions

View File

@ -551,23 +551,29 @@ export class ApPersonService implements OnModuleInit {
// Update user // Update user
await this.usersRepository.update(exist.id, updates); await this.usersRepository.update(exist.id, updates);
const publicKeys = new Map<string, IKey>(); try {
if (person.publicKey) { // Deleteアクティビティ受信時にもここが走ってsaveがuserforeign key制約エラーを吐くことがある
(person.additionalPublicKeys ?? []).forEach(key => publicKeys.set(key.id, key)); // とりあえずtry-catchで囲っておく
publicKeys.set(person.publicKey.id, person.publicKey); const publicKeys = new Map<string, IKey>();
if (person.publicKey) {
(person.additionalPublicKeys ?? []).forEach(key => publicKeys.set(key.id, key));
publicKeys.set(person.publicKey.id, person.publicKey);
await this.userPublickeysRepository.save(Array.from(publicKeys.values(), key => ({ await this.userPublickeysRepository.save(Array.from(publicKeys.values(), key => ({
keyId: key.id, keyId: key.id,
userId: exist.id,
keyPem: key.publicKeyPem,
})));
}
this.userPublickeysRepository.delete({
keyId: Not(In(Array.from(publicKeys.keys()))),
userId: exist.id, userId: exist.id,
keyPem: key.publicKeyPem, });
}))); } catch (err) {
this.logger.error('something happened while updating remote user public keys:', { err });
} }
this.userPublickeysRepository.delete({
keyId: Not(In(Array.from(publicKeys.keys()))),
userId: exist.id,
});
let _description: string | null = null; let _description: string | null = null;
if (person._misskey_summary) { if (person._misskey_summary) {