diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/sellershut/src/entity/user/followers/followers_page.rs | 0 | ||||
-rw-r--r-- | crates/sellershut/src/server/routes/users/followers.rs | 38 |
2 files changed, 38 insertions, 0 deletions
diff --git a/crates/sellershut/src/entity/user/followers/followers_page.rs b/crates/sellershut/src/entity/user/followers/followers_page.rs new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/crates/sellershut/src/entity/user/followers/followers_page.rs diff --git a/crates/sellershut/src/server/routes/users/followers.rs b/crates/sellershut/src/server/routes/users/followers.rs new file mode 100644 index 0000000..ecc5bf0 --- /dev/null +++ b/crates/sellershut/src/server/routes/users/followers.rs @@ -0,0 +1,38 @@ +use activitypub_federation::{ + axum::json::FederationJson, config::Data, protocol::context::WithContext, traits::Object, +}; +use axum::{ + debug_handler, + extract::{Path, Query}, + http::{StatusCode, Uri}, + response::IntoResponse, +}; +use serde::Deserialize; +use tracing::trace; + +use crate::{entity::user::followers::Follower, error::AppError, state::AppHandle}; + +#[derive(Deserialize)] +pub struct Cursor { + pub cursor: Option<String>, +} + +#[debug_handler] +pub async fn http_get_followers( + Path(name): Path<String>, + Query(cursor): Query<Cursor>, + uri: Uri, + data: Data<AppHandle>, +) -> Result<impl IntoResponse, AppError> { + trace!(uri = uri.path(), "getting"); + let follower = Follower { + user_id: uri.path().to_string(), + cursor: cursor.cursor, + }; + let json_user = follower.into_json(&data).await?; + Ok(( + StatusCode::OK, + FederationJson(WithContext::new_default(json_user)), + ) + .into_response()) +} |