add: polls backend

TODO: polls frontend
This commit is contained in:
trisua 2025-06-03 23:35:34 -04:00
parent b5e060e8ae
commit 4dfa09207e
18 changed files with 574 additions and 17 deletions

View file

@ -19,7 +19,7 @@ use serde::Deserialize;
use tetratto_core::model::{
communities::{
CommunityContext, CommunityJoinAccess, CommunityReadAccess, CommunityWriteAccess,
PostContext,
PollOption, PostContext,
},
communities_permissions::CommunityPermission,
permissions::FinePermission,
@ -113,6 +113,10 @@ pub fn routes() -> Router {
"/posts/{id}/context",
post(communities::posts::update_context_request),
)
.route(
"/posts/{id}/poll_vote",
post(communities::posts::vote_request),
)
// drafts
.route("/drafts", post(communities::drafts::create_request))
.route("/drafts/{id}", delete(communities::drafts::delete_request))
@ -419,6 +423,14 @@ pub struct UpdateCommunityJoinAccess {
pub access: CommunityJoinAccess,
}
#[derive(Deserialize)]
pub struct CreatePostPoll {
pub option_a: String,
pub option_b: String,
pub option_c: String,
pub option_d: String,
}
#[derive(Deserialize)]
pub struct CreatePost {
pub content: String,
@ -427,6 +439,8 @@ pub struct CreatePost {
pub replying_to: Option<String>,
#[serde(default)]
pub answering: String,
#[serde(default)]
pub poll: Option<CreatePostPoll>,
}
#[derive(Deserialize)]
@ -597,3 +611,8 @@ pub struct UpdateEmojiName {
pub struct CreatePostDraft {
pub content: String,
}
#[derive(Deserialize)]
pub struct VoteInPoll {
pub option: PollOption,
}