v3: added comment likes, added votes/likes list view, added db migrations mechanism, updated project dependencies
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 42s

This commit is contained in:
khannurien
2026-06-21 14:17:56 +00:00
parent 888aae45cf
commit 7afb5d3f07
25 changed files with 1475 additions and 840 deletions

View File

@@ -15,9 +15,11 @@ import {
ORPHANED_ATTACHMENTS_RETENTION_HOURS,
UNUSED_INVITES_RETENTION_DAYS,
} from "../config.ts";
import { runMigrations } from "../sql/migrate.ts";
export const db = new DatabaseSync(DB_PATH);
db.exec("PRAGMA foreign_keys = ON;");
runMigrations(db);
// Purge expired/used password reset tokens on startup
db.prepare(
@@ -236,6 +238,7 @@ export interface CommentRow {
created_at: string;
updated_at: string | null;
deleted: number;
like_count: number;
author_username: string;
author_avatar_mime: string | null;
[key: string]: SQLOutputValue;
@@ -255,6 +258,7 @@ export function isCommentRow(
"updated_at" in obj &&
(typeof obj.updated_at === "string" || obj.updated_at === null) &&
"deleted" in obj && typeof obj.deleted === "number" &&
"like_count" in obj && typeof obj.like_count === "number" &&
"author_username" in obj && typeof obj.author_username === "string" &&
"author_avatar_mime" in obj &&
(typeof obj.author_avatar_mime === "string" ||
@@ -271,6 +275,7 @@ export function commentRowToApi(row: CommentRow): Comment {
createdAt: new Date(row.created_at),
updatedAt: row.updated_at ? new Date(row.updated_at) : undefined,
deleted: Boolean(row.deleted),
likeCount: row.like_count,
authorUsername: row.author_username,
authorAvatarMime: row.author_avatar_mime ?? undefined,
};

View File

@@ -255,6 +255,7 @@ export interface Comment {
createdAt: Date;
updatedAt?: Date;
deleted: boolean;
likeCount: number;
authorUsername: string;
authorAvatarMime?: string;
}
@@ -469,11 +470,23 @@ export interface VoteRemoveMessage {
dumpId: string;
}
export interface CommentLikeCastMessage {
type: "comment_like_cast";
commentId: string;
}
export interface CommentLikeRemoveMessage {
type: "comment_like_remove";
commentId: string;
}
export type ClientToServerMessage =
| PingMessage
| PongMessage
| VoteCastMessage
| VoteRemoveMessage;
| VoteRemoveMessage
| CommentLikeCastMessage
| CommentLikeRemoveMessage;
// ── Server → Client ──────────────────────────────────────────────────────────
@@ -488,6 +501,7 @@ export interface WelcomeMessage {
type: "welcome";
users: OnlineUser[];
myVotes: string[];
myCommentLikes: string[];
unreadNotificationCount: number;
}
@@ -511,6 +525,21 @@ export interface VoteAckMessage {
voteCount: number;
}
export interface CommentLikesUpdateMessage {
type: "comment_likes_update";
commentId: string;
likeCount: number;
likerId: string;
action: "cast" | "remove";
}
export interface CommentLikeAckMessage {
type: "comment_like_ack";
commentId: string;
action: "cast" | "remove";
likeCount: number;
}
export interface DumpCreatedMessage {
type: "dump_created";
dump: Dump;
@@ -589,6 +618,8 @@ export type ServerToClientMessage =
| PresenceUpdateMessage
| VotesUpdateMessage
| VoteAckMessage
| CommentLikesUpdateMessage
| CommentLikeAckMessage
| DumpCreatedMessage
| DumpUpdatedMessage
| DumpDeletedMessage
@@ -624,7 +655,8 @@ export type NotificationType =
| "playlist_dump_added"
| "dump_upvoted"
| "user_mentioned"
| "dump_commented";
| "dump_commented"
| "comment_liked";
export interface PlaylistFollowedData {
followerId: string;
@@ -676,6 +708,14 @@ export interface DumpCommentedData {
dumpTitle: string;
}
export interface CommentLikedData {
likerId: string;
likerUsername: string;
commentId: string;
dumpId: string;
dumpTitle: string;
}
export type NotificationData =
| PlaylistFollowedData
| UserFollowedData
@@ -683,7 +723,8 @@ export type NotificationData =
| PlaylistDumpAddedData
| DumpUpvotedData
| UserMentionedData
| DumpCommentedData;
| DumpCommentedData
| CommentLikedData;
export interface Notification {
id: string;