forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat; ScheduledNoteDeleteのQueue関連を実装 * feat: ノート作成時に削除する時間を指定できるように * feat: ノートに削除予定時刻を含めるように * feat: APIのレスポンスにノートの削除予定時刻を含めるように * update: types * fix: QueueProcessorModuleへの追記漏れを修正 * feat: PostFormに削除予定時刻のエディタを実装 * update: MkDeleteScheduleEditorにタイトルを追加 * feat: 自己消滅するノートにはアイコンを表示するように * fix: ノートの自己消滅を設定しても下書きが保存されない問題を修正 * fix: BullBoardにscheduledNoteDeleteQueueが表示されない問題を修正
- Loading branch information
1 parent
77b4470
commit 285087d
Showing
23 changed files
with
785 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/backend/migration/1709187210308-scheduled-note-delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export class ScheduledNoteDelete1709187210308 { | ||
name = 'ScheduledNoteDelete1709187210308' | ||
|
||
async up(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "note" ADD "deleteAt" TIMESTAMP WITH TIME ZONE`); | ||
} | ||
|
||
async down(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "deleteAt"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/backend/src/queue/processors/ScheduledNoteDeleteProsessorService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { DI } from '@/di-symbols.js'; | ||
import type { NotesRepository, UsersRepository } from '@/models/_.js'; | ||
import type Logger from '@/logger.js'; | ||
import { bindThis } from '@/decorators.js'; | ||
import { NoteDeleteService } from '@/core/NoteDeleteService.js'; | ||
import { QueueLoggerService } from '../QueueLoggerService.js'; | ||
import type * as Bull from 'bullmq'; | ||
import type { ScheduledNoteDeleteJobData } from '../types.js'; | ||
|
||
@Injectable() | ||
export class ScheduledNoteDeleteProcessorService { | ||
private logger: Logger; | ||
|
||
constructor( | ||
@Inject(DI.notesRepository) | ||
private notesRepository: NotesRepository, | ||
|
||
@Inject(DI.usersRepository) | ||
private usersRepository: UsersRepository, | ||
|
||
private noteDeleteService: NoteDeleteService, | ||
private queueLoggerService: QueueLoggerService, | ||
) { | ||
this.logger = this.queueLoggerService.logger.createSubLogger('scheduled-note-delete'); | ||
} | ||
|
||
@bindThis | ||
public async process(job: Bull.Job<ScheduledNoteDeleteJobData>): Promise<void> { | ||
const note = await this.notesRepository.findOneBy({ id: job.data.noteId }); | ||
if (note == null) { | ||
return; | ||
} | ||
|
||
const user = await this.usersRepository.findOneBy({ id: note.userId }); | ||
if (user == null) { | ||
return; | ||
} | ||
|
||
await this.noteDeleteService.delete(user, note); | ||
this.logger.info(`Deleted note ${note.id}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.