diff options
author | rtkay123 <dev@kanjala.com> | 2025-07-22 13:27:05 +0200 |
---|---|---|
committer | rtkay123 <dev@kanjala.com> | 2025-07-22 13:27:05 +0200 |
commit | e0c23477bd07c86522df6e972fbdb7a70d647431 (patch) | |
tree | 18bca2d802487088f6cdeacb2850ef7bccdb1278 | |
parent | 377487e86984441041c23261515bb907fe8a8d06 (diff) | |
download | sellershut-e0c23477bd07c86522df6e972fbdb7a70d647431.tar.bz2 sellershut-e0c23477bd07c86522df6e972fbdb7a70d647431.zip |
test(integration): followers
-rw-r--r-- | contrib/bruno/users/followers.bru | 15 | ||||
-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 |
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()) +} |