add: town square forum config
This commit is contained in:
parent
d4ff681310
commit
548a6dcf4e
8 changed files with 73 additions and 5 deletions
|
@ -266,8 +266,12 @@ pub struct CreatePostProps {
|
|||
pub from_draft: usize,
|
||||
#[serde(default)]
|
||||
pub quote: usize,
|
||||
#[serde(default)]
|
||||
pub topic: usize,
|
||||
#[serde(default, alias = "sig")]
|
||||
pub use_signature: bool,
|
||||
#[serde(default, alias = "topics")]
|
||||
pub show_topics: bool,
|
||||
}
|
||||
|
||||
/// `/communities/intents/post`
|
||||
|
@ -350,6 +354,20 @@ pub async fn create_post_request(
|
|||
None
|
||||
};
|
||||
|
||||
// fetch topics
|
||||
let topics = if props.show_topics {
|
||||
if props.community != 0 {
|
||||
match data.0.get_community_by_id_no_void(props.community).await {
|
||||
Ok(x) => x.topics,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
}
|
||||
} else {
|
||||
HashMap::new()
|
||||
}
|
||||
} else {
|
||||
HashMap::new()
|
||||
};
|
||||
|
||||
// ...
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0.0, lang, &Some(user)).await;
|
||||
|
@ -361,7 +379,10 @@ pub async fn create_post_request(
|
|||
context.insert("communities", &communities);
|
||||
context.insert("selected_stack", &props.stack);
|
||||
context.insert("selected_community", &props.community);
|
||||
context.insert("selected_topic", &props.topic);
|
||||
context.insert("use_signature", &props.use_signature);
|
||||
context.insert("topics", &topics);
|
||||
context.insert("show_topics", &props.show_topics);
|
||||
|
||||
// return
|
||||
Ok(Html(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue