diff options
| author | Marie <github@yuugi.dev> | 2025-05-08 09:16:09 +0000 |
|---|---|---|
| committer | Marie <github@yuugi.dev> | 2025-05-08 09:16:09 +0000 |
| commit | 0d6b52ab3a7b3f066409cab48bc38216c439e68c (patch) | |
| tree | 5ade430eb547984d8f48c59eb22d3fcf0b3dd622 /packages/backend/src/server/api/endpoints | |
| parent | merge: reverts the check in `usingBunnyCdn` back and some lint fixes caused b... (diff) | |
| parent | Fix polls not rendering properly in Schedule List (diff) | |
| download | sharkey-0d6b52ab3a7b3f066409cab48bc38216c439e68c.tar.gz sharkey-0d6b52ab3a7b3f066409cab48bc38216c439e68c.tar.bz2 sharkey-0d6b52ab3a7b3f066409cab48bc38216c439e68c.zip | |
merge: Fix polls not rendering properly in Schedule List (!990)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/990
Closes #1049
Approved-by: Hazelnoot <acomputerdog@gmail.com>
Approved-by: dakkar <dakkar@thenautilus.net>
Diffstat (limited to 'packages/backend/src/server/api/endpoints')
| -rw-r--r-- | packages/backend/src/server/api/endpoints/notes/schedule/list.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/schedule/list.ts b/packages/backend/src/server/api/endpoints/notes/schedule/list.ts index 3665348b97..cbf3a961c0 100644 --- a/packages/backend/src/server/api/endpoints/notes/schedule/list.ts +++ b/packages/backend/src/server/api/endpoints/notes/schedule/list.ts @@ -133,6 +133,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- renote, reply, renoteId: item.note.renote, replyId: item.note.reply, + poll: item.note.poll ? await this.fillPoll(item.note.poll) : undefined, }, }; })); @@ -155,4 +156,21 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- } return null; } + + // Pulled from NoteEntityService and modified to work with MiNoteSchedule + // originally planned to use directly from NoteEntityService but since the poll doesn't actually exist yet that doesn't work + @bindThis + private async fillPoll(poll: { multiple: boolean; choices: string[]; expiresAt: string | null }) { + const choices = poll.choices.map(c => ({ + text: c, + votes: 0, // Default to 0 as there will never be any registered votes while scheduled + isVoted: false, // Default to false as the author can't vote anyways since the poll does not exist in the repo yet + })); + + return { + multiple: poll.multiple, + expiresAt: poll.expiresAt ? new Date(poll.expiresAt).toISOString() : null, + choices, + }; + } } |