}
// Check for a site ban
- if UserView::read(&conn, user_id)?.banned {
+ let user = User_::read(&conn, user_id)?;
+ if user.banned {
return Err(APIError::err("site_ban").into());
}
Err(_e) => return Err(APIError::err("couldnt_create_post").into()),
};
- post_create(&inserted_post, conn)?;
+ post_create(&inserted_post, &user, conn)?;
// They like their own post by default
let like_form = PostLikeForm {
use crate::apub::{get_apub_protocol_string, get_following_instances};
use crate::db::post::Post;
use crate::db::user::User_;
-use crate::db::Crud;
use activitystreams::activity::Create;
use activitystreams::context;
use diesel::PgConnection;
use failure::Error;
use isahc::prelude::*;
-pub fn post_create(post: &Post, conn: &PgConnection) -> Result<(), Error> {
- let user = User_::read(conn, post.creator_id)?;
+pub fn post_create(post: &Post, creator: &User_, conn: &PgConnection) -> Result<(), Error> {
let page = post.as_page(conn)?;
let mut create = Create::new();
create.object_props.set_context_xsd_any_uri(context())?;
create
.object_props
.set_id(page.object_props.get_id().unwrap().to_string())?;
- create.create_props.set_actor_xsd_any_uri(user.actor_id)?;
+ create
+ .create_props
+ .set_actor_xsd_any_uri(creator.actor_id.to_owned())?;
create.create_props.set_object_base_box(page)?;
let json = serde_json::to_string(&create)?;
for i in get_following_instances() {
use diesel::PgConnection;
use failure::Error;
-pub async fn inbox(
+// TODO: need a proper actor that has this inbox
+
+pub async fn create_inbox(
create: web::Json<Create>,
db: web::Data<Pool<ConnectionManager<PgConnection>>>,
) -> Result<HttpResponse, Error> {
"/federation/communities",
web::get().to(apub::community::get_apub_community_list),
)
- // TODO: need a proper actor that has this inbox
- .route("/federation/inbox", web::post().to(apub::inbox::inbox))
+ .route(
+ "/federation/inbox",
+ web::post().to(apub::inbox::create_inbox),
+ )
.route(
"/federation/c/{community_name}",
web::get().to(apub::community::get_apub_community_http),