147 lines
3.7 KiB
TypeScript
147 lines
3.7 KiB
TypeScript
/**
|
|
* Notifications: their types, and the data each type carries.
|
|
*
|
|
* @module
|
|
*/
|
|
|
|
/** What a notification is about. */
|
|
export type NotificationType =
|
|
| "playlist_followed"
|
|
| "user_followed"
|
|
| "user_dump_posted"
|
|
| "playlist_dump_added"
|
|
| "dump_upvoted"
|
|
| "user_mentioned"
|
|
| "dump_commented"
|
|
| "comment_liked";
|
|
|
|
/** `playlist_followed`: someone followed one of the user's playlists. */
|
|
export interface PlaylistFollowedData {
|
|
/** The follower's id. */
|
|
followerId: string;
|
|
/** The follower's name. */
|
|
followerUsername: string;
|
|
/** The playlist's id. */
|
|
playlistId: string;
|
|
/** The playlist's title. */
|
|
playlistTitle: string;
|
|
}
|
|
|
|
/** `user_followed`: someone followed the user. */
|
|
export interface UserFollowedData {
|
|
/** The follower's id. */
|
|
followerId: string;
|
|
/** The follower's name. */
|
|
followerUsername: string;
|
|
}
|
|
|
|
/** `user_dump_posted`: a user they follow posted a dump. */
|
|
export interface UserDumpPostedData {
|
|
/** The poster's id. */
|
|
dumperId: string;
|
|
/** The poster's name. */
|
|
dumperUsername: string;
|
|
/** The dump's id. */
|
|
dumpId: string;
|
|
/** The dump's title. */
|
|
dumpTitle: string;
|
|
}
|
|
|
|
/** `playlist_dump_added`: a dump was added to a playlist they follow. */
|
|
export interface PlaylistDumpAddedData {
|
|
/** The dump's id. */
|
|
dumpId: string;
|
|
/** The dump's title. */
|
|
dumpTitle: string;
|
|
/** The playlist's id. */
|
|
playlistId: string;
|
|
/** The playlist's title. */
|
|
playlistTitle: string;
|
|
}
|
|
|
|
/** `dump_upvoted`: someone upvoted one of the user's dumps. */
|
|
export interface DumpUpvotedData {
|
|
/** The voter's id. */
|
|
voterId: string;
|
|
/** The voter's name. */
|
|
voterUsername: string;
|
|
/** The dump's id. */
|
|
dumpId: string;
|
|
/** The dump's title. */
|
|
dumpTitle: string;
|
|
}
|
|
|
|
/** `user_mentioned`: someone @mentioned the user. */
|
|
export interface UserMentionedData {
|
|
/** The mentioner's id. */
|
|
mentionerId: string;
|
|
/** The mentioner's name. */
|
|
mentionerUsername: string;
|
|
/** Where the mention was written. */
|
|
contextType: "comment" | "dump" | "playlist" | "chat";
|
|
/** The id of the comment, dump, playlist or chat message. */
|
|
contextId: string;
|
|
/**
|
|
* The title of the dump or playlist, or of the dump a comment is under;
|
|
* empty for the chat.
|
|
*/
|
|
contextTitle: string;
|
|
/** The dump a comment is under, for a mention in a comment. */
|
|
dumpId?: string;
|
|
}
|
|
|
|
/** `dump_commented`: someone commented on one of the user's dumps. */
|
|
export interface DumpCommentedData {
|
|
/** The commenter's id. */
|
|
commenterId: string;
|
|
/** The commenter's name. */
|
|
commenterUsername: string;
|
|
/** The comment's id. */
|
|
commentId: string;
|
|
/** The dump's id. */
|
|
dumpId: string;
|
|
/** The dump's title. */
|
|
dumpTitle: string;
|
|
}
|
|
|
|
/** `comment_liked`: someone liked one of the user's comments. */
|
|
export interface CommentLikedData {
|
|
/** The liker's id. */
|
|
likerId: string;
|
|
/** The liker's name. */
|
|
likerUsername: string;
|
|
/** The comment's id. */
|
|
commentId: string;
|
|
/** The id of the dump it is under. */
|
|
dumpId: string;
|
|
/** The title of the dump it is under. */
|
|
dumpTitle: string;
|
|
}
|
|
|
|
/** The data of any notification; its {@link NotificationType} says which. */
|
|
export type NotificationData =
|
|
| PlaylistFollowedData
|
|
| UserFollowedData
|
|
| UserDumpPostedData
|
|
| PlaylistDumpAddedData
|
|
| DumpUpvotedData
|
|
| UserMentionedData
|
|
| DumpCommentedData
|
|
| CommentLikedData;
|
|
|
|
/** A notification sent to a user. */
|
|
export interface Notification {
|
|
/** The notification's id. */
|
|
id: string;
|
|
/** The id of the user it is for. */
|
|
userId: string;
|
|
/** What it is about. */
|
|
type: NotificationType;
|
|
/** Its details, shaped by `type`. */
|
|
data: NotificationData;
|
|
/** Whether the user has read it. */
|
|
read: boolean;
|
|
/** When it was sent. */
|
|
createdAt: Date;
|
|
}
|