2023-07-27 07:31:52 +02:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-02-27 03:07:39 +01:00
|
|
|
import { notificationTypes } from '@/types.js';
|
2022-01-18 14:27:10 +01:00
|
|
|
|
2024-01-30 11:53:53 +01:00
|
|
|
const baseSchema = {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
format: 'id',
|
|
|
|
},
|
|
|
|
createdAt: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
format: 'date-time',
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2023-11-02 07:57:55 +01:00
|
|
|
enum: [...notificationTypes, 'reaction:grouped', 'renote:grouped'],
|
2022-01-18 14:27:10 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
},
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
export const packedNotificationSchema = {
|
|
|
|
type: 'object',
|
|
|
|
oneOf: [{
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['note'],
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['mention'],
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['reply'],
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['renote'],
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['quote'],
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['reaction'],
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
reaction: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['pollEnded'],
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['follow'],
|
|
|
|
},
|
|
|
|
user: {
|
|
|
|
type: 'object',
|
|
|
|
ref: 'UserLite',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
userId: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
format: 'id',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['receiveFollowRequest'],
|
|
|
|
},
|
|
|
|
user: {
|
|
|
|
type: 'object',
|
|
|
|
ref: 'UserLite',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
userId: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
format: 'id',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['followRequestAccepted'],
|
|
|
|
},
|
|
|
|
user: {
|
|
|
|
type: 'object',
|
|
|
|
ref: 'UserLite',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
userId: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
format: 'id',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['roleAssigned'],
|
|
|
|
},
|
|
|
|
role: {
|
|
|
|
type: 'object',
|
|
|
|
ref: 'Role',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['achievementEarned'],
|
|
|
|
},
|
|
|
|
achievement: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['app'],
|
|
|
|
},
|
|
|
|
body: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
header: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['reaction:grouped'],
|
|
|
|
},
|
|
|
|
note: {
|
|
|
|
type: 'object',
|
|
|
|
ref: 'Note',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
reactions: {
|
|
|
|
type: 'array',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
items: {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
user: {
|
|
|
|
type: 'object',
|
|
|
|
ref: 'UserLite',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
reaction: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
2023-11-02 07:57:55 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
required: ['user', 'reaction'],
|
2023-11-02 07:57:55 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['renote:grouped'],
|
|
|
|
},
|
|
|
|
note: {
|
2023-11-21 03:13:56 +01:00
|
|
|
type: 'object',
|
2024-01-30 11:53:53 +01:00
|
|
|
ref: 'Note',
|
2023-11-21 03:13:56 +01:00
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
users: {
|
|
|
|
type: 'array',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
items: {
|
|
|
|
type: 'object',
|
|
|
|
ref: 'UserLite',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
},
|
|
|
|
},
|
2023-11-02 07:57:55 +01:00
|
|
|
},
|
2024-01-30 11:53:53 +01:00
|
|
|
}, {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
...baseSchema.properties,
|
|
|
|
type: {
|
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
|
|
|
enum: ['test'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}],
|
2022-01-18 14:27:10 +01:00
|
|
|
} as const;
|