From 9d480e3fba2828f3223c8d9d654eb22963f1e85a Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sat, 22 Feb 2025 23:17:54 +0100 Subject: [PATCH] [backend/api] Fix API errors on poll vote --- Iceshrimp.Backend/Controllers/Web/NoteController.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Iceshrimp.Backend/Controllers/Web/NoteController.cs b/Iceshrimp.Backend/Controllers/Web/NoteController.cs index 649355ef..09267ce5 100644 --- a/Iceshrimp.Backend/Controllers/Web/NoteController.cs +++ b/Iceshrimp.Backend/Controllers/Web/NoteController.cs @@ -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