Make it possible to display remote blogs
This commit is contained in:
+3
-3
@@ -16,7 +16,7 @@ use utils;
|
||||
|
||||
#[get("/~/<name>", rank = 2)]
|
||||
fn details(name: String, conn: DbConn, user: Option<User>) -> Template {
|
||||
let blog = Blog::find_by_actor_id(&*conn, name).unwrap();
|
||||
let blog = Blog::find_by_fqn(&*conn, name).unwrap();
|
||||
let recents = Post::get_recents_for_blog(&*conn, &blog, 5);
|
||||
Template::render("blogs/details", json!({
|
||||
"blog": blog,
|
||||
@@ -34,7 +34,7 @@ fn details(name: String, conn: DbConn, user: Option<User>) -> Template {
|
||||
|
||||
#[get("/~/<name>", format = "application/activity+json", rank = 1)]
|
||||
fn activity_details(name: String, conn: DbConn) -> ActivityPub {
|
||||
let blog = Blog::find_by_actor_id(&*conn, name).unwrap();
|
||||
let blog = Blog::find_local(&*conn, name).unwrap();
|
||||
blog.as_activity_pub(&*conn)
|
||||
}
|
||||
|
||||
@@ -74,6 +74,6 @@ fn create(conn: DbConn, data: Form<NewBlogForm>, user: User) -> Redirect {
|
||||
|
||||
#[get("/~/<name>/outbox")]
|
||||
fn outbox(name: String, conn: DbConn) -> Outbox {
|
||||
let blog = Blog::find_by_actor_id(&*conn, name).unwrap();
|
||||
let blog = Blog::find_local(&*conn, name).unwrap();
|
||||
blog.outbox(&*conn)
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ use utils;
|
||||
|
||||
#[get("/~/<blog>/<slug>", rank = 4)]
|
||||
fn details(blog: String, slug: String, conn: DbConn, user: Option<User>) -> Template {
|
||||
let blog = Blog::find_by_actor_id(&*conn, blog).unwrap();
|
||||
let blog = Blog::find_by_fqn(&*conn, blog).unwrap();
|
||||
let post = Post::find_by_slug(&*conn, slug).unwrap();
|
||||
let comments = Comment::find_by_post(&*conn, post.id);
|
||||
Template::render("posts/details", json!({
|
||||
@@ -68,7 +68,7 @@ struct NewPostForm {
|
||||
|
||||
#[post("/~/<blog_name>/new", data = "<data>")]
|
||||
fn create(blog_name: String, data: Form<NewPostForm>, user: User, conn: DbConn) -> Redirect {
|
||||
let blog = Blog::find_by_actor_id(&*conn, blog_name.to_string()).unwrap();
|
||||
let blog = Blog::find_by_fqn(&*conn, blog_name.to_string()).unwrap();
|
||||
let form = data.get();
|
||||
let slug = form.title.to_string().to_kebab_case();
|
||||
let post = Post::insert(&*conn, NewPost {
|
||||
|
||||
@@ -36,7 +36,7 @@ fn webfinger(query: WebfingerQuery, conn: DbConn) -> Content<Result<String, &'st
|
||||
if res_dom == BASE_URL.as_str() {
|
||||
let res = match User::find_local(&*conn, String::from(user)) {
|
||||
Some(usr) => Ok(usr.webfinger(&*conn)),
|
||||
None => match Blog::find_by_actor_id(&*conn, String::from(user)) {
|
||||
None => match Blog::find_local(&*conn, String::from(user)) {
|
||||
Some(blog) => Ok(blog.webfinger(&*conn)),
|
||||
None => Err("Requested actor not found")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user