summary refs log tree commit diff
diff options
context:
space:
mode:
authorCyberL1 <cyber.hf18@gmail.com>2026-06-24 14:06:48 +0200
committerRory& <root@rory.gay>2026-06-25 17:56:49 +0200
commit4cf0e48dd0ff91a7bd70334abe986b12dfa5d089 (patch)
treefaacf8d6f2352ac7fee209f30f05cdfaf6f3c684
parentfix: add `expiry` field to polls in message handling (diff)
downloadserver-ts-4cf0e48dd0ff91a7bd70334abe986b12dfa5d089.tar.xz
fix: assign id to poll answers
-rw-r--r--assets/openapi.json2
-rw-r--r--assets/schemas.json2
-rw-r--r--src/api/util/handlers/Message.ts6
-rw-r--r--src/schemas/api/messages/Polls.ts2
4 files changed, 9 insertions, 3 deletions
diff --git a/assets/openapi.json b/assets/openapi.json

index cb36dd63..a6ccabe4 100644 --- a/assets/openapi.json +++ b/assets/openapi.json
@@ -12463,7 +12463,7 @@ "type": "object", "properties": { "answer_id": { - "type": "string" + "type": "integer" }, "poll_media": { "$ref": "#/components/schemas/PollMedia" diff --git a/assets/schemas.json b/assets/schemas.json
index de6311a5..c1f47bce 100644 --- a/assets/schemas.json +++ b/assets/schemas.json
@@ -13229,7 +13229,7 @@ "type": "object", "properties": { "answer_id": { - "type": "string" + "type": "integer" }, "poll_media": { "$ref": "#/definitions/PollMedia" diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index 21204992..3b2fda51 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -490,6 +490,12 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { message.poll.expiry = new Date(Date.now() + opts.poll.duration * 3600000); } + if (message.poll && opts.poll?.answers) { + for (let i = 0; i < opts.poll.answers.length; i++) { + message.poll.answers[i].answer_id = i; + } + } + await handleMessageMentionsAsync(message); const attachmentIndices = new Map(message.attachments?.map((attachment, index) => [`attachment://${attachment.filename}`, index])); diff --git a/src/schemas/api/messages/Polls.ts b/src/schemas/api/messages/Polls.ts
index 85fe69b3..bd655561 100644 --- a/src/schemas/api/messages/Polls.ts +++ b/src/schemas/api/messages/Polls.ts
@@ -32,7 +32,7 @@ export interface PollMedia { } export interface PollAnswer { - answer_id?: string; + answer_id?: number; poll_media: PollMedia; }