summaryrefslogtreecommitdiffstats
path: root/server/src/api/post.rs
diff options
context:
space:
mode:
authorFelix Ableitner <me@nutomic.com>2020-05-28 20:09:37 +0200
committerFelix Ableitner <me@nutomic.com>2020-05-28 20:09:37 +0200
commitd6e21192772a5631968fe5ddb51049287c34eba7 (patch)
tree0b500e79ea79b699dcae9f8071a4e3e45c531492 /server/src/api/post.rs
parent8f9bd1fef7fe9abee04ef54672faad588823ddab (diff)
make comments work (more or less)
Diffstat (limited to 'server/src/api/post.rs')
-rw-r--r--server/src/api/post.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/server/src/api/post.rs b/server/src/api/post.rs
index 9bbde791..aee60732 100644
--- a/server/src/api/post.rs
+++ b/server/src/api/post.rs
@@ -34,6 +34,9 @@ use diesel::{
use failure::Error;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
+use crate::apub::get_apub_protocol_string;
+use crate::db::community::Community;
+use url::Url;
#[derive(Serialize, Deserialize, Debug)]
pub struct CreatePost {
@@ -190,7 +193,17 @@ impl Perform for Oper<CreatePost> {
}
};
- let updated_post = match Post::update_ap_id(&conn, inserted_post.id) {
+ // TODO: we should be able to remove Post::update_ap_id with this
+ let community = Url::parse(&Community::read(&conn, data.community_id)?.actor_id)?;
+ let apub_id =
+ format!(
+ "{}://{}/{}/{}",
+ get_apub_protocol_string(),
+ community.domain().ok_or(format_err!("community has invalid domain"))?,
+ "post",
+ inserted_post.id
+ );
+ let updated_post = match Post::update_ap_id(&conn, inserted_post.id, &apub_id) {
Ok(post) => post,
Err(_e) => return Err(APIError::err("couldnt_create_post").into()),
};