Stores likes on comments and keeps each comment's like_count in step with them. Likes have no HTTP endpoint to cast or remove. The WebSocket route (routes/ws.ts) calls this module on comment_like_cast and comment_like_remove messages, then broadcasts the new count. The comment routes use it only to list a comment's likers.

Functions

f
castCommentLike(
commentId: string,
userId: string
): LikeResult

Records userId's like on a comment and notifies the comment's author. The notification is best-effort: if it fails, the like still counts.

f
getCommentLikers(
commentId: string,
page: number,
limit: number
): Page<User>

Returns a page of the users who like a comment, latest like first, for GET /api/comments/:commentId/likers. It doesn't check that the caller may see the comment: the route does that first, with getDump.

f
getUserCommentLikes(userId: string): string[]

Returns the ids of the comments userId likes. The WebSocket route sends them in its welcome message, and the client shows those like buttons pressed.

f
removeCommentLike(
commentId: string,
userId: string
): LikeResult

Takes back userId's like on a comment. It doesn't check that the user can still see the comment, since a like on a dump that has gone private is still theirs to take back.

Interfaces

I
LikeResult

Returned to the WebSocket route by castCommentLike and removeCommentLike. The route acks the liker with likeCount, then broadcasts it to every client, or to the liker's alone when the comment's dump isPrivate.