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