refactor: use GetValidatedDTO for vote validation

This commit is contained in:
2026-01-10 23:01:15 +01:00
parent 6cdad79caa
commit e2804ca07e

View File

@@ -78,14 +78,13 @@ func (h *VoteHandler) CastVote(w http.ResponseWriter, r *http.Request) {
return return
} }
req, ok := GetValidatedDTO[dto.CastVoteRequest](r) request, ok := GetValidatedDTO[dto.CastVoteRequest](w, r)
if !ok { if !ok {
SendErrorResponse(w, "Invalid request", http.StatusBadRequest)
return return
} }
var voteType database.VoteType var voteType database.VoteType
switch req.Type { switch request.Type {
case "up": case "up":
voteType = database.VoteUp voteType = database.VoteUp
case "down": case "down":