Stores upvotes on dumps and keeps each dump's vote_count in step with them.

Voting has no HTTP endpoint. The WebSocket route (routes/ws.ts) calls this module on vote_cast and vote_remove messages, then broadcasts the new count. routes/dumps.ts uses it only to list a dump's voters.

Functions

f
castVote(
dumpId: string,
userId: string
): VoteResult

Records userId's upvote on a dump and notifies the dump's poster. The notification is best-effort: if it fails, the vote still counts.

f
getDumpVoters(
dumpId: string,
page: number,
limit: number
): Page<User>

Returns a page of the users who upvoted a dump, latest vote first, for GET /api/dumps/:dumpId/voters. It doesn't check that the caller may see the dump: the route does that first, with getDump.

f
getUserVotes(userId: string): string[]

Returns the ids of the dumps userId upvoted. The WebSocket route sends them in its welcome message, and the client shows those vote buttons pressed.

f
removeVote(
dumpId: string,
userId: string
): VoteResult

Takes back userId's upvote on a dump. No visibility check: taking back a vote on a dump that has since gone private is harmless, and it's the voter's own row.

Interfaces

I
VoteResult

Returned to the WebSocket route by castVote and removeVote. The route acks the voter with voteCount, then broadcasts it to every client, or to the dump owner's alone when isPrivate.