summaryrefslogtreecommitdiff
path: root/src/invite/handlers/accept
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-10-27 17:41:22 -0400
committerOwen Jacobson <owen@grimoire.ca>2025-10-28 01:42:29 -0400
commitf305e487d619f1d993d11d728c8cf7261bf3b371 (patch)
tree46ab6203babd5b93dcce00a0b7af7ae86dc0945e /src/invite/handlers/accept
parent6de7402a002791c6216b12a40e74af9c8ab82c02 (diff)
Convert `Invites` into a freestanding component.
Diffstat (limited to 'src/invite/handlers/accept')
-rw-r--r--src/invite/handlers/accept/mod.rs8
-rw-r--r--src/invite/handlers/accept/test.rs12
2 files changed, 9 insertions, 11 deletions
diff --git a/src/invite/handlers/accept/mod.rs b/src/invite/handlers/accept/mod.rs
index cdf385f..8bdaa51 100644
--- a/src/invite/handlers/accept/mod.rs
+++ b/src/invite/handlers/accept/mod.rs
@@ -5,11 +5,10 @@ use axum::{
};
use crate::{
- app::App,
clock::RequestedAt,
empty::Empty,
error::{Internal, NotFound},
- invite::{app, handlers::PathInfo},
+ invite::{app, app::Invites, handlers::PathInfo},
name::Name,
password::Password,
token::extract::IdentityCookie,
@@ -19,14 +18,13 @@ use crate::{
mod test;
pub async fn handler(
- State(app): State<App>,
+ State(invites): State<Invites>,
RequestedAt(accepted_at): RequestedAt,
identity: IdentityCookie,
Path(invite): Path<PathInfo>,
Json(request): Json<Request>,
) -> Result<(IdentityCookie, Empty), Error> {
- let secret = app
- .invites()
+ let secret = invites
.accept(&invite, &request.name, &request.password, &accepted_at)
.await
.map_err(Error)?;
diff --git a/src/invite/handlers/accept/test.rs b/src/invite/handlers/accept/test.rs
index 283ec76..446dbf9 100644
--- a/src/invite/handlers/accept/test.rs
+++ b/src/invite/handlers/accept/test.rs
@@ -24,7 +24,7 @@ async fn valid_invite() {
password: password.clone(),
};
let (identity, Empty) = super::handler(
- State(app.clone()),
+ State(app.invites()),
fixtures::now(),
identity,
Path(invite.id),
@@ -67,7 +67,7 @@ async fn nonexistent_invite() {
password: password.clone(),
};
let super::Error(error) = super::handler(
- State(app.clone()),
+ State(app.invites()),
fixtures::now(),
identity,
Path(invite.clone()),
@@ -103,7 +103,7 @@ async fn expired_invite() {
password: password.clone(),
};
let super::Error(error) = super::handler(
- State(app.clone()),
+ State(app.invites()),
fixtures::now(),
identity,
Path(invite.id.clone()),
@@ -140,7 +140,7 @@ async fn accepted_invite() {
password: password.clone(),
};
let super::Error(error) = super::handler(
- State(app.clone()),
+ State(app.invites()),
fixtures::now(),
identity,
Path(invite.id.clone()),
@@ -183,7 +183,7 @@ async fn conflicting_name() {
password: password.clone(),
};
let super::Error(error) = super::handler(
- State(app.clone()),
+ State(app.invites()),
fixtures::now(),
identity,
Path(invite.id.clone()),
@@ -217,7 +217,7 @@ async fn invalid_name() {
password: password.clone(),
};
let super::Error(error) = super::handler(
- State(app.clone()),
+ State(app.invites()),
fixtures::now(),
identity,
Path(invite.id),