mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 22:09:16 +01:00
Add poll database schema and basic implementation
Co-authored-by: CPlusPatch <42910258+CPlusPatch@users.noreply.github.com>
This commit is contained in:
parent
8645093a3f
commit
31171b5fc7
6 changed files with 455 additions and 3 deletions
|
|
@ -115,6 +115,16 @@ export const findManyNotes = async (
|
|||
...userRelations,
|
||||
},
|
||||
},
|
||||
poll: {
|
||||
with: {
|
||||
options: {
|
||||
with: {
|
||||
votes: true,
|
||||
},
|
||||
},
|
||||
votes: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
extras: {
|
||||
pinned: userId
|
||||
|
|
@ -141,6 +151,16 @@ export const findManyNotes = async (
|
|||
},
|
||||
reply: true,
|
||||
quote: true,
|
||||
poll: {
|
||||
with: {
|
||||
options: {
|
||||
with: {
|
||||
votes: true,
|
||||
},
|
||||
},
|
||||
votes: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
extras: {
|
||||
pinned: userId
|
||||
|
|
@ -176,6 +196,10 @@ export const findManyNotes = async (
|
|||
})),
|
||||
attachments: post.attachments.map((attachment) => attachment.media),
|
||||
emojis: (post.emojis ?? []).map((emoji) => emoji.emoji),
|
||||
poll: post.poll ? {
|
||||
...post.poll,
|
||||
options: post.poll.options.sort((a, b) => a.index - b.index),
|
||||
} : null,
|
||||
reblog: post.reblog && {
|
||||
...post.reblog,
|
||||
author: transformOutputToUserWithRelations(post.reblog.author),
|
||||
|
|
@ -187,6 +211,10 @@ export const findManyNotes = async (
|
|||
(attachment) => attachment.media,
|
||||
),
|
||||
emojis: (post.reblog.emojis ?? []).map((emoji) => emoji.emoji),
|
||||
poll: post.reblog.poll ? {
|
||||
...post.reblog.poll,
|
||||
options: post.reblog.poll.options.sort((a, b) => a.index - b.index),
|
||||
} : null,
|
||||
pinned: Boolean(post.reblog.pinned),
|
||||
reblogged: Boolean(post.reblog.reblogged),
|
||||
muted: Boolean(post.reblog.muted),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue