Merge 2a01e6753a
into d522d1bf26
This commit is contained in:
commit
0f0de63439
|
@ -14,8 +14,10 @@ import { UtilityService } from '@/core/UtilityService.js';
|
|||
import type { MiNote } from '@/models/Note.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
||||
import { QueueService } from '../QueueService.js';
|
||||
import { getApId } from './type.js';
|
||||
import { ApPersonService } from './models/ApPersonService.js';
|
||||
import type { DbQueue } from '../QueueModule.js';
|
||||
import type { IObject } from './type.js';
|
||||
|
||||
export type UriParseResult = {
|
||||
|
@ -52,6 +54,10 @@ export class ApDbResolverService implements OnApplicationShutdown {
|
|||
@Inject(DI.userPublickeysRepository)
|
||||
private userPublickeysRepository: UserPublickeysRepository,
|
||||
|
||||
@Inject('queue:db')
|
||||
public dbQueue: DbQueue,
|
||||
|
||||
private queueService: QueueService,
|
||||
private cacheService: CacheService,
|
||||
private apPersonService: ApPersonService,
|
||||
private utilityService: UtilityService,
|
||||
|
@ -159,7 +165,21 @@ export class ApDbResolverService implements OnApplicationShutdown {
|
|||
key: MiUserPublickey | null;
|
||||
} | null> {
|
||||
const user = await this.apPersonService.resolvePerson(uri) as MiRemoteUser;
|
||||
if (user.isDeleted) return null;
|
||||
if (user.isDeleted) {
|
||||
const jobs = await this.dbQueue.getJobs(['active', 'delayed', 'paused', 'wait', 'waiting', 'waiting-children']);
|
||||
|
||||
const isUserDeletingNow = jobs.filter(e => e.name === 'deleteAccount').map(e => JSON.parse(e.data)).find(e => e.user.id === user.id);
|
||||
|
||||
if (isUserDeletingNow) {
|
||||
return null;
|
||||
} else {
|
||||
// If user deleted but job not running, job may failed so re-run the job
|
||||
// @FIXME: soft deleted account will be forced to hard deleted, but soft deletion not used at this time
|
||||
await this.queueService.createDeleteAccountJob(user);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const key = await this.publicKeyByUserIdCache.fetch(
|
||||
user.id,
|
||||
|
|
|
@ -14,6 +14,7 @@ import type { MiNote } from '@/models/Note.js';
|
|||
import { EmailService } from '@/core/EmailService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { SearchService } from '@/core/SearchService.js';
|
||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbUserDeleteJobData } from '../types.js';
|
||||
|
@ -39,6 +40,7 @@ export class DeleteAccountProcessorService {
|
|||
private emailService: EmailService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private searchService: SearchService,
|
||||
private globalEventService: GlobalEventService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('delete-account');
|
||||
}
|
||||
|
@ -126,6 +128,9 @@ export class DeleteAccountProcessorService {
|
|||
// nop
|
||||
} else {
|
||||
await this.usersRepository.delete(job.data.user.id);
|
||||
|
||||
// Trigger CacheService
|
||||
this.globalEventService.publishInternalEvent('remoteUserUpdated', { id: job.data.user.id });
|
||||
}
|
||||
|
||||
return 'Account deleted';
|
||||
|
|
Loading…
Reference in New Issue