mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-27 22:39:33 +09:00
parent
0082f6f8e8
commit
2a622b02dc
@ -30,8 +30,6 @@ export class AccountUpdateService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
// Circular dependency
|
|
||||||
// AccountUpdateService - ApDeliverManagerSevice( - DeliverManager) - UserKeypairService - AccountUpdateService
|
|
||||||
this.apDeliverManagerService = this.moduleRef.get(ApDeliverManagerService.name);
|
this.apDeliverManagerService = this.moduleRef.get(ApDeliverManagerService.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import type { MiUserKeypair } from '@/models/UserKeypair.js';
|
|||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { GlobalEventService, GlobalEvents } from '@/core/GlobalEventService.js';
|
import { GlobalEventService, GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
import { AccountUpdateService } from '@/core/AccountUpdateService.js';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserKeypairService implements OnApplicationShutdown {
|
export class UserKeypairService implements OnApplicationShutdown {
|
||||||
@ -28,7 +27,6 @@ export class UserKeypairService implements OnApplicationShutdown {
|
|||||||
private userKeypairsRepository: UserKeypairsRepository,
|
private userKeypairsRepository: UserKeypairsRepository,
|
||||||
|
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
private accountUpdateService: AccountUpdateService,
|
|
||||||
) {
|
) {
|
||||||
this.cache = new RedisKVCache<MiUserKeypair>(this.redisClient, 'userKeypair', {
|
this.cache = new RedisKVCache<MiUserKeypair>(this.redisClient, 'userKeypair', {
|
||||||
lifetime: 1000 * 60 * 60 * 24, // 24h
|
lifetime: 1000 * 60 * 60 * 24, // 24h
|
||||||
@ -56,15 +54,12 @@ export class UserKeypairService implements OnApplicationShutdown {
|
|||||||
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;
|
||||||
|
|
||||||
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 });
|
||||||
// リモートに配信
|
|
||||||
await this.accountUpdateService.publishToFollowers(userId, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -13,6 +13,7 @@ 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 { UserKeypairService } from '../UserKeypairService.js';
|
||||||
|
import { AccountUpdateService } from '@/core/AccountUpdateService.js';
|
||||||
|
|
||||||
interface IRecipe {
|
interface IRecipe {
|
||||||
type: string;
|
type: string;
|
||||||
@ -50,6 +51,7 @@ class DeliverManager {
|
|||||||
private userKeypairService: UserKeypairService,
|
private userKeypairService: UserKeypairService,
|
||||||
private followingsRepository: FollowingsRepository,
|
private followingsRepository: FollowingsRepository,
|
||||||
private queueService: QueueService,
|
private queueService: QueueService,
|
||||||
|
private accountUpdateService: AccountUpdateService,
|
||||||
|
|
||||||
actor: { id: MiUser['id']; host: null; },
|
actor: { id: MiUser['id']; host: null; },
|
||||||
activity: IActivity | null,
|
activity: IActivity | null,
|
||||||
@ -111,6 +113,8 @@ class DeliverManager {
|
|||||||
* ed25519の署名がなければ追加する
|
* ed25519の署名がなければ追加する
|
||||||
*/
|
*/
|
||||||
await this.userKeypairService.refreshAndprepareEd25519KeyPair(this.actor.id);
|
await this.userKeypairService.refreshAndprepareEd25519KeyPair(this.actor.id);
|
||||||
|
// リモートに配信
|
||||||
|
await this.accountUpdateService.publishToFollowers(this.actor.id, true);
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -165,6 +169,7 @@ export class ApDeliverManagerService {
|
|||||||
|
|
||||||
private userKeypairService: UserKeypairService,
|
private userKeypairService: UserKeypairService,
|
||||||
private queueService: QueueService,
|
private queueService: QueueService,
|
||||||
|
private accountUpdateService: AccountUpdateService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +185,7 @@ export class ApDeliverManagerService {
|
|||||||
this.userKeypairService,
|
this.userKeypairService,
|
||||||
this.followingsRepository,
|
this.followingsRepository,
|
||||||
this.queueService,
|
this.queueService,
|
||||||
|
this.accountUpdateService,
|
||||||
actor,
|
actor,
|
||||||
activity,
|
activity,
|
||||||
);
|
);
|
||||||
@ -199,6 +205,7 @@ export class ApDeliverManagerService {
|
|||||||
this.userKeypairService,
|
this.userKeypairService,
|
||||||
this.followingsRepository,
|
this.followingsRepository,
|
||||||
this.queueService,
|
this.queueService,
|
||||||
|
this.accountUpdateService,
|
||||||
actor,
|
actor,
|
||||||
activity,
|
activity,
|
||||||
);
|
);
|
||||||
@ -212,6 +219,7 @@ export class ApDeliverManagerService {
|
|||||||
this.userKeypairService,
|
this.userKeypairService,
|
||||||
this.followingsRepository,
|
this.followingsRepository,
|
||||||
this.queueService,
|
this.queueService,
|
||||||
|
this.accountUpdateService,
|
||||||
actor,
|
actor,
|
||||||
activity,
|
activity,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user