summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarie <github@yuugi.dev>2025-05-08 01:26:56 +0200
committerMarie <github@yuugi.dev>2025-05-08 01:26:56 +0200
commitcfad5999b2340b6acbc9eb643e115ac7de63b49f (patch)
treecfad015f0ca7e77e5ce177a7337afc5c3cf2582c
parentmerge: Show all files for Drive Cleaner (!982) (diff)
downloadsharkey-cfad5999b2340b6acbc9eb643e115ac7de63b49f.tar.gz
sharkey-cfad5999b2340b6acbc9eb643e115ac7de63b49f.tar.bz2
sharkey-cfad5999b2340b6acbc9eb643e115ac7de63b49f.zip
Fix polls not rendering properly in Schedule List
-rw-r--r--packages/backend/src/server/api/endpoints/notes/schedule/list.ts18
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,
+ };
+ }
}