summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorMarie <github@yuugi.dev>2024-11-04 11:22:37 +0100
committerMarie <github@yuugi.dev>2024-12-09 05:33:19 +0100
commit1d3c8253981fba2d431df2f5cc12dd78b21d37bc (patch)
tree263d59f8f07b27d4d6192c2273eca3195e5e8bc1 /packages/backend/src
parentchore: remove from note required type (diff)
downloadsharkey-1d3c8253981fba2d431df2f5cc12dd78b21d37bc.tar.gz
sharkey-1d3c8253981fba2d431df2f5cc12dd78b21d37bc.tar.bz2
sharkey-1d3c8253981fba2d431df2f5cc12dd78b21d37bc.zip
upd: add notification for when scheduled note gets posted
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/entities/NotificationEntityService.ts2
-rw-r--r--packages/backend/src/models/Notification.ts5
-rw-r--r--packages/backend/src/models/json-schema/notification.ts25
-rw-r--r--packages/backend/src/queue/processors/ScheduleNotePostProcessorService.ts5
-rw-r--r--packages/backend/src/types.ts1
5 files changed, 36 insertions, 2 deletions
diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts
index 447d95cc68..31a9809323 100644
--- a/packages/backend/src/core/entities/NotificationEntityService.ts
+++ b/packages/backend/src/core/entities/NotificationEntityService.ts
@@ -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 {
diff --git a/packages/backend/src/models/Notification.ts b/packages/backend/src/models/Notification.ts
index 5003e02d96..53003a0a5a 100644
--- a/packages/backend/src/models/Notification.ts
+++ b/packages/backend/src/models/Notification.ts
@@ -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 | {
diff --git a/packages/backend/src/models/json-schema/notification.ts b/packages/backend/src/models/json-schema/notification.ts
index 69bd9531ec..26498e3e9d 100644
--- a/packages/backend/src/models/json-schema/notification.ts
+++ b/packages/backend/src/models/json-schema/notification.ts
@@ -390,6 +390,31 @@ export const packedNotificationSchema = {
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: {
+ ...baseSchema.properties,
+ type: {
+ type: 'string',
+ optional: false, nullable: false,
enum: ['reaction:grouped'],
},
note: {
diff --git a/packages/backend/src/queue/processors/ScheduleNotePostProcessorService.ts b/packages/backend/src/queue/processors/ScheduleNotePostProcessorService.ts
index 59e23b865e..f281b0ed7b 100644
--- a/packages/backend/src/queue/processors/ScheduleNotePostProcessorService.ts
+++ b/packages/backend/src/queue/processors/ScheduleNotePostProcessorService.ts
@@ -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,
+ });
}
});
}
diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts
index 7930129002..95f049f768 100644
--- a/packages/backend/src/types.ts
+++ b/packages/backend/src/types.ts
@@ -36,6 +36,7 @@ export const notificationTypes = [
'achievementEarned',
'exportCompleted',
'scheduledNoteFailed',
+ 'scheduledNotePosted',
'app',
'test',
] as const;