summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/bruno/users/followers.bru15
-rw-r--r--crates/sellershut/src/entity/user/followers/followers_page.rs0
-rw-r--r--crates/sellershut/src/server/routes/users/followers.rs38
3 files changed, 53 insertions, 0 deletions
diff --git a/contrib/bruno/users/followers.bru b/contrib/bruno/users/followers.bru
new file mode 100644
index 0000000..e394d30
--- /dev/null
+++ b/contrib/bruno/users/followers.bru
@@ -0,0 +1,15 @@
+meta {
+ name: followers
+ type: http
+ seq: 4
+}
+
+get {
+ url: {{HUT_HOSTNAME}}/users/sellershut/followers
+ body: none
+ auth: inherit
+}
+
+assert {
+ res.status: eq 200
+}
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())
+}