[backend/federation] Fix remote poll voter counts (ISH-363)

This commit is contained in:
Laura Hausmann 2024-06-15 17:00:19 +02:00
parent 8b36f1aecf
commit 946eed1b03
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -24,6 +24,10 @@ public class PollService(
return;
}
if (updateVotersCount)
await db.Database
.ExecuteSqlAsync($"""UPDATE "poll" SET "votersCount" = GREATEST("votersCount", (SELECT COUNT(*) FROM (SELECT DISTINCT "userId" FROM "poll_vote" WHERE "noteId" = {poll.NoteId}) AS sq)::integer) WHERE "noteId" = {poll.NoteId};""");
var vote = activityRenderer.RenderVote(pollVote, poll, note);
var actor = userRenderer.RenderLite(pollVote.User);
var activity = ActivityPub.ActivityRenderer.RenderCreate(vote, actor);