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.
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.
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.
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.
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.
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.
Usage
import * as mod from "api/services/vote-service.ts";