mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-04-28 09:36:56 +00:00
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/920 Closes #931 and #936 Approved-by: Marie <github@yuugi.dev> Approved-by: Julia <julia@insertdomain.name>
This commit is contained in:
commit
92bac81a7f
2 changed files with 42 additions and 2 deletions
|
@ -9,7 +9,7 @@ import { IsNull, In, MoreThan, Not } from 'typeorm';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { MiLocalUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
||||
import type { BlockingsRepository, FollowingsRepository, InstancesRepository, MiMeta, MutingsRepository, UserListMembershipsRepository, UsersRepository } from '@/models/_.js';
|
||||
import type { BlockingsRepository, FollowingsRepository, InstancesRepository, MiMeta, MutingsRepository, UserListMembershipsRepository, UsersRepository, NoteScheduleRepository, MiNoteSchedule } from '@/models/_.js';
|
||||
import type { RelationshipJobData, ThinUser } from '@/queue/types.js';
|
||||
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
|
@ -49,6 +49,9 @@ export class AccountMoveService {
|
|||
@Inject(DI.instancesRepository)
|
||||
private instancesRepository: InstancesRepository,
|
||||
|
||||
@Inject(DI.noteScheduleRepository)
|
||||
private noteScheduleRepository: NoteScheduleRepository,
|
||||
|
||||
private userEntityService: UserEntityService,
|
||||
private idService: IdService,
|
||||
private apPersonService: ApPersonService,
|
||||
|
@ -119,6 +122,7 @@ export class AccountMoveService {
|
|||
await Promise.all([
|
||||
this.copyBlocking(src, dst),
|
||||
this.copyMutings(src, dst),
|
||||
this.deleteScheduledNotes(src),
|
||||
this.updateLists(src, dst),
|
||||
]);
|
||||
} catch {
|
||||
|
@ -201,6 +205,21 @@ export class AccountMoveService {
|
|||
await this.mutingsRepository.insert(arrayToInsert);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async deleteScheduledNotes(src: ThinUser): Promise<void> {
|
||||
const scheduledNotes = await this.noteScheduleRepository.findBy({
|
||||
userId: src.id,
|
||||
}) as MiNoteSchedule[];
|
||||
|
||||
for (const note of scheduledNotes) {
|
||||
await this.queueService.ScheduleNotePostQueue.remove(`schedNote:${note.id}`);
|
||||
}
|
||||
|
||||
await this.noteScheduleRepository.delete({
|
||||
userId: src.id,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update lists while moving accounts.
|
||||
* - No removal of the old account from the lists
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { MoreThan } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { DriveFilesRepository, NoteReactionsRepository, NotesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type { DriveFilesRepository, NoteReactionsRepository, NotesRepository, UserProfilesRepository, UsersRepository, NoteScheduleRepository, MiNoteSchedule } from '@/models/_.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import { DriveService } from '@/core/DriveService.js';
|
||||
import type { MiDriveFile } from '@/models/DriveFile.js';
|
||||
|
@ -20,6 +20,7 @@ import { ReactionService } from '@/core/ReactionService.js';
|
|||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbUserDeleteJobData } from '../types.js';
|
||||
import { QueueService } from '@/core/QueueService.js';
|
||||
|
||||
@Injectable()
|
||||
export class DeleteAccountProcessorService {
|
||||
|
@ -41,6 +42,10 @@ export class DeleteAccountProcessorService {
|
|||
@Inject(DI.noteReactionsRepository)
|
||||
private noteReactionsRepository: NoteReactionsRepository,
|
||||
|
||||
@Inject(DI.noteScheduleRepository)
|
||||
private noteScheduleRepository: NoteScheduleRepository,
|
||||
|
||||
private queueService: QueueService,
|
||||
private driveService: DriveService,
|
||||
private emailService: EmailService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
|
@ -60,6 +65,22 @@ export class DeleteAccountProcessorService {
|
|||
return;
|
||||
}
|
||||
|
||||
{ // Delete scheduled notes
|
||||
const scheduledNotes = await this.noteScheduleRepository.findBy({
|
||||
userId: user.id,
|
||||
}) as MiNoteSchedule[];
|
||||
|
||||
for (const note of scheduledNotes) {
|
||||
await this.queueService.ScheduleNotePostQueue.remove(`schedNote:${note.id}`);
|
||||
}
|
||||
|
||||
await this.noteScheduleRepository.delete({
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
this.logger.succ('All scheduled notes deleted');
|
||||
}
|
||||
|
||||
{ // Delete notes
|
||||
let cursor: MiNote['id'] | null = null;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue