Compute outbox/inbox URLs from activity_pub::Actor
This commit is contained in:
+6
-8
@@ -30,14 +30,12 @@ fn create(conn: DbConn, data: Form<NewBlogForm>, _user: User) -> Redirect {
|
||||
let form = data.get();
|
||||
let slug = utils::make_actor_id(form.title.to_string());
|
||||
|
||||
Blog::insert(&*conn, NewBlog {
|
||||
actor_id: slug.to_string(),
|
||||
title: form.title.to_string(),
|
||||
summary: String::from(""),
|
||||
outbox_url: Blog::compute_outbox(slug.to_string(), inst.public_domain.to_string()),
|
||||
inbox_url: Blog::compute_inbox(slug.to_string(), inst.public_domain.to_string()),
|
||||
instance_id: inst.id
|
||||
});
|
||||
Blog::insert(&*conn, NewBlog::new_local(
|
||||
slug.to_string(),
|
||||
form.title.to_string(),
|
||||
String::from(""),
|
||||
inst.id
|
||||
)).update_boxes(&*conn);
|
||||
|
||||
Redirect::to(format!("/~/{}", slug).as_str())
|
||||
}
|
||||
|
||||
+10
-11
@@ -6,6 +6,7 @@ use std::collections::HashMap;
|
||||
use db_conn::DbConn;
|
||||
use models::user::*;
|
||||
use models::instance::Instance;
|
||||
use activity_pub::Actor;
|
||||
|
||||
#[get("/me")]
|
||||
fn me(user: User) -> String {
|
||||
@@ -36,17 +37,15 @@ fn create(conn: DbConn, data: Form<NewUserForm>) -> Redirect {
|
||||
let form = data.get();
|
||||
|
||||
if form.password == form.password_confirmation {
|
||||
User::insert(&*conn, NewUser {
|
||||
username: form.username.to_string(),
|
||||
display_name: form.username.to_string(),
|
||||
outbox_url: User::compute_outbox(form.username.to_string(), inst.public_domain.to_string()),
|
||||
inbox_url: User::compute_inbox(form.username.to_string(), inst.public_domain.to_string()),
|
||||
is_admin: !inst.has_admin(&*conn),
|
||||
summary: String::from(""),
|
||||
email: Some(form.email.to_string()),
|
||||
hashed_password: Some(User::hash_pass(form.password.to_string())),
|
||||
instance_id: inst.id
|
||||
});
|
||||
User::insert(&*conn, NewUser::new_local(
|
||||
form.username.to_string(),
|
||||
form.username.to_string(),
|
||||
!inst.has_admin(&*conn),
|
||||
String::from(""),
|
||||
form.email.to_string(),
|
||||
User::hash_pass(form.password.to_string()),
|
||||
inst.id
|
||||
)).update_boxes(&*conn);
|
||||
}
|
||||
|
||||
Redirect::to(format!("/@/{}", data.get().username).as_str())
|
||||
|
||||
Reference in New Issue
Block a user