upd: add notification for when scheduled note gets posted
This commit is contained in:
parent
170093f2a2
commit
1d3c825398
13 changed files with 77 additions and 9 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 | {
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ export const notificationTypes = [
|
|||
'achievementEarned',
|
||||
'exportCompleted',
|
||||
'scheduledNoteFailed',
|
||||
'scheduledNotePosted',
|
||||
'app',
|
||||
'test',
|
||||
] as const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue