[backend/api] Fix API errors on poll vote
This commit is contained in:
parent
d33e2d7bcc
commit
9d480e3fba
1 changed files with 5 additions and 6 deletions
|
@ -515,15 +515,14 @@ public class NoteController(
|
|||
throw GracefulException.BadRequest("At least one vote must be included");
|
||||
|
||||
var target = await db.Notes
|
||||
.Where(p => p.Id == id)
|
||||
.EnsureVisibleFor(user)
|
||||
.IncludeCommonProperties()
|
||||
.Include(p => p.Poll)
|
||||
.Where(p => p.Id == id && p.Poll != null)
|
||||
.EnsureVisibleFor(user)
|
||||
.FirstOrDefaultAsync()
|
||||
?? throw GracefulException.NotFound("Note not found");
|
||||
if (target.Poll == null)
|
||||
throw GracefulException.NotFound("Poll not found");
|
||||
?? throw GracefulException.NotFound("Poll not found");
|
||||
|
||||
if (target.Poll.ExpiresAt != null && target.Poll.ExpiresAt < DateTime.UtcNow)
|
||||
if (target.Poll!.ExpiresAt != null && target.Poll.ExpiresAt < DateTime.UtcNow)
|
||||
throw GracefulException.NotFound("Poll has expired");
|
||||
|
||||
var voted = await db.PollVotes
|
||||
|
|
Loading…
Add table
Reference in a new issue