upd: add notification for when scheduled note gets posted

This commit is contained in:
Marie 2024-11-04 11:22:37 +01:00
parent 170093f2a2
commit 1d3c825398
No known key found for this signature in database
GPG key ID: 7ADF6C9CD9A28555
13 changed files with 77 additions and 9 deletions

View file

@ -20,7 +20,7 @@ import type { OnModuleInit } from '@nestjs/common';
import type { UserEntityService } from './UserEntityService.js';
import type { NoteEntityService } from './NoteEntityService.js';
const NOTE_REQUIRED_NOTIFICATION_TYPES = new Set(['note', 'mention', 'reply', 'renote', 'renote:grouped', 'quote', 'reaction', 'reaction:grouped', 'pollEnded', 'edited'] as (typeof groupedNotificationTypes[number])[]);
const NOTE_REQUIRED_NOTIFICATION_TYPES = new Set(['note', 'mention', 'reply', 'renote', 'renote:grouped', 'quote', 'reaction', 'reaction:grouped', 'pollEnded', 'edited', 'scheduledNotePosted'] as (typeof groupedNotificationTypes[number])[]);
@Injectable()
export class NotificationEntityService implements OnModuleInit {

View file

@ -127,6 +127,11 @@ export type MiNotification = {
id: string;
createdAt: string;
reason: string;
} | {
type: 'scheduledNotePosted';
id: string;
createdAt: string;
noteId: MiNote['id'];
};
export type MiGroupedNotification = MiNotification | {

View file

@ -383,6 +383,31 @@ export const packedNotificationSchema = {
optional: false, nullable: false,
},
},
}, {
type: 'object',
properties: {
...baseSchema.properties,
type: {
type: 'string',
optional: false, nullable: false,
enum: ['scheduledNotePosted'],
},
user: {
type: 'object',
ref: 'UserLite',
optional: false, nullable: false,
},
userId: {
type: 'string',
optional: false, nullable: false,
format: 'id',
},
note: {
type: 'object',
ref: 'Note',
optional: false, nullable: false,
},
},
}, {
type: 'object',
properties: {

View file

@ -107,7 +107,7 @@ export class ScheduleNotePostProcessorService {
return;
}
await this.noteCreateService.create(me, {
const createdNote = await this.noteCreateService.create(me, {
...note,
createdAt: new Date(),
files,
@ -121,6 +121,9 @@ export class ScheduleNotePostProcessorService {
channel,
});
await this.noteScheduleRepository.remove(data);
this.notificationService.createNotification(me.id, 'scheduledNotePosted', {
noteId: createdNote.id,
});
}
});
}

View file

@ -36,6 +36,7 @@ export const notificationTypes = [
'achievementEarned',
'exportCompleted',
'scheduledNoteFailed',
'scheduledNotePosted',
'app',
'test',
] as const;