v3: added a chatbox
Some checks failed
Build and Publish Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
khannurien
2026-06-29 20:25:10 +00:00
parent f171027673
commit 6c4f410d9b
35 changed files with 1800 additions and 152 deletions

View File

@@ -216,6 +216,30 @@ export function deserializeComment(raw: RawComment): Comment {
};
}
/**
* Chat
*/
export interface ChatMessage {
id: string;
userId: string;
body: string;
createdAt: Date;
updatedAt?: Date;
authorUsername: string;
authorAvatarMime?: string;
}
export type RawChatMessage = WithStringDate<ChatMessage>;
export function deserializeChatMessage(raw: RawChatMessage): ChatMessage {
return {
...raw,
createdAt: new Date(raw.createdAt),
updatedAt: raw.updatedAt ? new Date(raw.updatedAt) : undefined,
};
}
/**
* Playlists
*/
@@ -328,7 +352,7 @@ export interface DumpUpvotedData {
export interface UserMentionedData {
mentionerId: string;
mentionerUsername: string;
contextType: "comment" | "dump" | "playlist";
contextType: "comment" | "dump" | "playlist" | "chat";
contextId: string;
contextTitle: string;
dumpId?: string;
@@ -498,6 +522,21 @@ export interface WSForceLogoutMessage {
type: "force_logout";
}
export interface WSChatMessageMessage {
type: "chat_message";
message: RawChatMessage;
}
export interface WSChatMessageUpdatedMessage {
type: "chat_message_updated";
message: RawChatMessage;
}
export interface WSChatMessageDeletedMessage {
type: "chat_message_deleted";
id: string;
}
export type IncomingWSMessage =
| WSPingMessage
| WSWelcomeMessage
@@ -519,7 +558,10 @@ export type IncomingWSMessage =
| WSCommentDeletedMessage
| WSNotificationCreatedMessage
| WSErrorMessage
| WSForceLogoutMessage;
| WSForceLogoutMessage
| WSChatMessageMessage
| WSChatMessageUpdatedMessage
| WSChatMessageDeletedMessage;
/**
* WebSocket messages — client → server (outgoing)
@@ -545,12 +587,37 @@ export interface WSCommentLikeRemoveMessage {
commentId: string;
}
export interface WSChatSendMessage {
type: "chat_send";
body: string;
}
export interface WSChatFocusMessage {
type: "chat_focus";
open: boolean;
}
export interface WSChatEditMessage {
type: "chat_edit";
id: string;
body: string;
}
export interface WSChatDeleteMessage {
type: "chat_delete";
id: string;
}
export type OutgoingWSMessage =
| WSPongMessage
| WSVoteCastMessage
| WSVoteRemoveMessage
| WSCommentLikeCastMessage
| WSCommentLikeRemoveMessage;
| WSCommentLikeRemoveMessage
| WSChatSendMessage
| WSChatFocusMessage
| WSChatEditMessage
| WSChatDeleteMessage;
/**
* Follows