Add ActivityPub endpoint for actors

This commit is contained in:
Bat
2018-04-23 16:09:05 +01:00
parent 9eb1b987b2
commit 7b3a884ec6
6 changed files with 29 additions and 4 deletions
+9 -2
View File
@@ -1,22 +1,29 @@
use rocket::request::Form;
use rocket::response::Redirect;
use rocket_contrib::Template;
use rocket_contrib::{Json, Template};
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 {
format!("Logged in as {}", user.username.to_string())
}
#[get("/@/<name>")]
#[get("/@/<name>", rank = 2)]
fn details(name: String) -> String {
format!("Hello, @{}", name)
}
#[get("/@/<name>", format = "application/activity+json", rank = 1)]
fn activity(name: String, conn: DbConn) -> Json {
let user = User::find_by_name(&*conn, name).unwrap();
Json(user.as_activity_pub())
}
#[get("/users/new")]
fn new() -> Template {
Template::render("users/new", HashMap::<String, i32>::new())