Skip to content

Commit c35ff4b

Browse files
Copilotabraham
andcommitted
Add notifications_merged event type for streaming endpoints
Co-authored-by: abraham <3341+abraham@users.noreply.github.com>
1 parent 08225df commit c35ff4b

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

dist/schema.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37108,6 +37108,20 @@
3710837108
"payload"
3710937109
]
3711037110
},
37111+
"NotificationsMergedEvent": {
37112+
"type": "object",
37113+
"description": "Accepted notification requests have finished merging, and the notifications list should be refreshed. Payload can be ignored.",
37114+
"properties": {
37115+
"event": {
37116+
"type": "string",
37117+
"description": "The type of event",
37118+
"$ref": "#/components/schemas/NotificationsMergedEventEventEnum"
37119+
}
37120+
},
37121+
"required": [
37122+
"event"
37123+
]
37124+
},
3711137125
"StreamingEvent": {
3711237126
"description": "Server-Sent Event from the Mastodon streaming API. The event field determines the type of payload.",
3711337127
"oneOf": [
@@ -37137,6 +37151,9 @@
3713737151
},
3713837152
{
3713937153
"$ref": "#/components/schemas/StatusUpdateEvent"
37154+
},
37155+
{
37156+
"$ref": "#/components/schemas/NotificationsMergedEvent"
3714037157
}
3714137158
]
3714237159
},
@@ -37166,6 +37183,9 @@
3716637183
},
3716737184
{
3716837185
"$ref": "#/components/schemas/StatusUpdateEvent"
37186+
},
37187+
{
37188+
"$ref": "#/components/schemas/NotificationsMergedEvent"
3716937189
}
3717037190
]
3717137191
},
@@ -37174,6 +37194,9 @@
3717437194
"oneOf": [
3717537195
{
3717637196
"$ref": "#/components/schemas/NotificationEvent"
37197+
},
37198+
{
37199+
"$ref": "#/components/schemas/NotificationsMergedEvent"
3717737200
}
3717837201
]
3717937202
},
@@ -37724,6 +37747,12 @@
3772437747
"enum": [
3772537748
"status.update"
3772637749
]
37750+
},
37751+
"NotificationsMergedEventEventEnum": {
37752+
"type": "string",
37753+
"enum": [
37754+
"notifications_merged"
37755+
]
3772737756
}
3772837757
},
3772937758
"securitySchemes": {

src/__tests__/generators/StreamingSchemaGenerator.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ describe('StreamingSchemaGenerator', () => {
5353
'AnnouncementDeleteEvent'
5454
);
5555
expect(spec.components?.schemas).toHaveProperty('StatusUpdateEvent');
56+
expect(spec.components?.schemas).toHaveProperty(
57+
'NotificationsMergedEvent'
58+
);
5659
});
5760

5861
it('should create combined streaming event schema', () => {
@@ -63,7 +66,7 @@ describe('StreamingSchemaGenerator', () => {
6366
'StreamingEvent'
6467
] as any;
6568
expect(streamingEvent.oneOf).toBeDefined();
66-
expect(streamingEvent.oneOf.length).toBe(9); // All event types
69+
expect(streamingEvent.oneOf.length).toBe(10); // All event types including notifications_merged
6770
});
6871

6972
it('should create endpoint-specific event schemas', () => {
@@ -147,7 +150,7 @@ describe('StreamingSchemaGenerator', () => {
147150

148151
const userEvent = spec.components?.schemas?.['StreamingUserEvent'] as any;
149152
expect(userEvent.oneOf).toBeDefined();
150-
expect(userEvent.oneOf.length).toBe(8); // All user events
153+
expect(userEvent.oneOf.length).toBe(9); // All user events including notifications_merged
151154

152155
// Check all expected event types are referenced
153156
const refs = userEvent.oneOf.map((ref: any) => ref.$ref);
@@ -159,6 +162,7 @@ describe('StreamingSchemaGenerator', () => {
159162
expect(refs).toContain('#/components/schemas/AnnouncementReactionEvent');
160163
expect(refs).toContain('#/components/schemas/AnnouncementDeleteEvent');
161164
expect(refs).toContain('#/components/schemas/StatusUpdateEvent');
165+
expect(refs).toContain('#/components/schemas/NotificationsMergedEvent');
162166
});
163167

164168
it('should create StreamingDirectEvent with only conversation event', () => {

src/generators/StreamingSchemaGenerator.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ const STREAMING_ENDPOINT_EVENTS: Record<string, string[]> = {
3131
'announcement.reaction',
3232
'announcement.delete',
3333
'status.update',
34+
'notifications_merged',
35+
],
36+
'/api/v1/streaming/user/notification': [
37+
'notification',
38+
'notifications_merged',
3439
],
35-
'/api/v1/streaming/user/notification': ['notification'],
3640
'/api/v1/streaming/public': ['update', 'delete', 'status.update'],
3741
'/api/v1/streaming/public/local': ['update', 'delete', 'status.update'],
3842
'/api/v1/streaming/public/remote': ['update', 'delete', 'status.update'],
@@ -100,6 +104,12 @@ const STREAMING_EVENTS: StreamingEventDefinition[] = [
100104
description:
101105
'A Status has been edited. Payload contains a Status cast to a string.',
102106
},
107+
{
108+
eventName: 'notifications_merged',
109+
payloadType: 'none',
110+
description:
111+
'Accepted notification requests have finished merging, and the notifications list should be refreshed. Payload can be ignored.',
112+
},
103113
];
104114

105115
/**

0 commit comments

Comments
 (0)