2019-12-19 21:59:13 +00:00
|
|
|
pub mod community;
|
|
|
|
pub mod post;
|
2019-12-27 17:25:07 +00:00
|
|
|
pub mod puller;
|
2019-12-19 21:59:13 +00:00
|
|
|
pub mod user;
|
|
|
|
use crate::Settings;
|
|
|
|
|
2020-03-16 17:30:25 +00:00
|
|
|
use actix_web::body::Body;
|
|
|
|
use actix_web::HttpResponse;
|
2019-12-19 21:59:13 +00:00
|
|
|
use std::fmt::Display;
|
2020-03-12 00:01:25 +00:00
|
|
|
use url::Url;
|
2019-12-19 21:59:13 +00:00
|
|
|
|
2020-03-16 17:30:25 +00:00
|
|
|
fn create_apub_response(json_data: String) -> HttpResponse<Body> {
|
|
|
|
HttpResponse::Ok()
|
|
|
|
.content_type("application/activity+json")
|
|
|
|
.body(json_data)
|
2019-12-19 21:59:13 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 17:26:58 +00:00
|
|
|
// TODO: this should take an enum community/user/post for `point`
|
|
|
|
// TODO: also not sure what exactly `value` should be (numeric id, name string, ...)
|
2020-03-16 17:30:25 +00:00
|
|
|
fn make_apub_endpoint<S: Display, T: Display>(point: S, value: T) -> Url {
|
2020-03-12 00:01:25 +00:00
|
|
|
Url::parse(&format!(
|
2020-02-29 17:38:47 +00:00
|
|
|
"{}://{}/federation/{}/{}",
|
|
|
|
get_apub_protocol_string(),
|
2019-12-19 21:59:13 +00:00
|
|
|
Settings::get().hostname,
|
|
|
|
point,
|
|
|
|
value
|
2020-03-12 00:01:25 +00:00
|
|
|
))
|
|
|
|
.unwrap()
|
2019-12-19 21:59:13 +00:00
|
|
|
}
|
2020-02-29 17:38:47 +00:00
|
|
|
|
2020-03-16 17:30:25 +00:00
|
|
|
fn get_apub_protocol_string() -> &'static str {
|
2020-02-29 17:38:47 +00:00
|
|
|
"http"
|
|
|
|
}
|