Add an AP followers endpoint for users
This commit is contained in:
parent
0ef12ff0f5
commit
92af83565e
@ -69,6 +69,7 @@ fn main() {
|
||||
routes::user::activity_details,
|
||||
routes::user::outbox,
|
||||
routes::user::inbox,
|
||||
routes::user::followers,
|
||||
routes::user::new,
|
||||
routes::user::create,
|
||||
|
||||
|
@ -4,8 +4,7 @@ use rocket_contrib::Template;
|
||||
use serde_json;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use activity_pub::ActivityPub;
|
||||
use activity_pub::activity;
|
||||
use activity_pub::{activity, activity_pub, ActivityPub, context};
|
||||
use activity_pub::actor::Actor;
|
||||
use activity_pub::inbox::Inbox;
|
||||
use activity_pub::outbox::Outbox;
|
||||
@ -90,3 +89,18 @@ fn inbox(name: String, conn: DbConn, data: String) -> String {
|
||||
user.received(&*conn, act);
|
||||
String::from("")
|
||||
}
|
||||
|
||||
#[get("/@/<name>/followers")]
|
||||
fn followers(name: String, conn: DbConn) -> ActivityPub {
|
||||
let user = User::find_local(&*conn, name).unwrap();
|
||||
let followers = user.get_followers(&*conn).into_iter().map(|f| f.compute_id(&*conn)).collect::<Vec<String>>();
|
||||
|
||||
let json = json!({
|
||||
"@context": context(),
|
||||
"id": user.compute_box(&*conn, "followers"),
|
||||
"type": "OrderedCollection",
|
||||
"totalItems": followers.len(),
|
||||
"orderedItems": followers
|
||||
});
|
||||
activity_pub(json)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user