summary refs log tree commit diff
diff options
context:
space:
mode:
authorCyberL1 <cyber.hf18@gmail.com>2026-06-25 00:04:21 +0200
committerRory& <root@rory.gay>2026-06-25 17:56:49 +0200
commiteae999789cd44c7208a182c47d1fcd2d8f0b0f54 (patch)
tree023dddcd101f4f69f8f5a79f8b87d42841d06153
parentfeat: add voting route (diff)
downloadserver-ts-eae999789cd44c7208a182c47d1fcd2d8f0b0f54.tar.xz
feat: set `me_voted` for poll messages
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts

index 554593ca..43fb8f9b 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -46,6 +46,7 @@ import { MessageCreateCloudAttachment, MessageCreateSchema, PartialUser, + PollAnswerCount, PublicMessage, Reaction, ReadStateType, @@ -213,6 +214,13 @@ router.get( return att; }) ?? []; + (x.poll?.results?.answer_counts as (PollAnswerCount & { voters?: string[] })[]).map((answer) => { + answer.me_voted = answer.voters!.includes(req.user_id); + delete answer.voters; + + return answer; + }); + /** Some clients ( discord.js ) only check if a property exists within the response, which causes errors when, say, the `application` property is `null`.