This commit is contained in:
parent
2a622b02dc
commit
31bf1dbc95
|
@ -49,17 +49,26 @@ export class UserKeypairService implements OnApplicationShutdown {
|
|||
return await this.cache.refresh(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userId user id
|
||||
* @returns Promise<boolean> true if keypair is created, false if keypair is already exists
|
||||
*/
|
||||
@bindThis
|
||||
public async refreshAndprepareEd25519KeyPair(userId: MiUser['id']): Promise<void> {
|
||||
public async refreshAndprepareEd25519KeyPair(userId: MiUser['id']): Promise<boolean> {
|
||||
await this.refresh(userId);
|
||||
const keypair = await this.cache.fetch(userId);
|
||||
if (keypair.ed25519PublicKey != null) return;
|
||||
if (keypair.ed25519PublicKey != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const ed25519 = await genEd25519KeyPair();
|
||||
await this.userKeypairsRepository.update({ userId }, {
|
||||
ed25519PublicKey: ed25519.publicKey,
|
||||
ed25519PrivateKey: ed25519.privateKey,
|
||||
});
|
||||
this.globalEventService.publishInternalEvent('userKeypairUpdated', { userId });
|
||||
return true;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
|
|
@ -12,8 +12,8 @@ import { QueueService } from '@/core/QueueService.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import type { IActivity } from '@/core/activitypub/type.js';
|
||||
import { ThinUser } from '@/queue/types.js';
|
||||
import { UserKeypairService } from '../UserKeypairService.js';
|
||||
import { AccountUpdateService } from '@/core/AccountUpdateService.js';
|
||||
import { UserKeypairService } from '../UserKeypairService.js';
|
||||
|
||||
interface IRecipe {
|
||||
type: string;
|
||||
|
@ -112,9 +112,11 @@ class DeliverManager {
|
|||
/**
|
||||
* ed25519の署名がなければ追加する
|
||||
*/
|
||||
await this.userKeypairService.refreshAndprepareEd25519KeyPair(this.actor.id);
|
||||
// リモートに配信
|
||||
await this.accountUpdateService.publishToFollowers(this.actor.id, true);
|
||||
const created = await this.userKeypairService.refreshAndprepareEd25519KeyPair(this.actor.id);
|
||||
if (created) {
|
||||
// リモートに配信
|
||||
await this.accountUpdateService.publishToFollowers(this.actor.id, true);
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
|
Loading…
Reference in New Issue