diff --git a/src/api/invitations.py b/src/api/invitations.py index 7792ffb..0921093 100644 --- a/src/api/invitations.py +++ b/src/api/invitations.py @@ -224,7 +224,7 @@ async def delete_invitation(invitation_id: PydanticObjectId, user: CurrentUserDe @invitations_router.post("/{invitation_id}/accept") -async def accept_invitation(invitation_id: PydanticObjectId, user: CurrentUserDep) -> Response: +async def accept_invitation(invitation_id: PydanticObjectId, user: CurrentUserDep) -> InvitationData: """Accept an invitation.""" invitation = await Invitation.get(invitation_id, fetch_links=True) if invitation is None: @@ -242,7 +242,7 @@ async def accept_invitation(invitation_id: PydanticObjectId, user: CurrentUserDe # Mark the invitation as accepted invitation.status = "accepted" invitation.responded_at = datetime.now(tz=UTC) - _ = await invitation.save() + _ = await invitation.replace() # Add the user to the event event = invitation.event @@ -262,11 +262,11 @@ async def accept_invitation(invitation_id: PydanticObjectId, user: CurrentUserDe ) notification = await notification.create() - return Response(status_code=status.HTTP_204_NO_CONTENT) + return InvitationData.from_invitation(invitation) @invitations_router.post("/{invitation_id}/decline") -async def decline_invitation(invitation_id: PydanticObjectId, user: CurrentUserDep) -> Response: +async def decline_invitation(invitation_id: PydanticObjectId, user: CurrentUserDep) -> InvitationData: """Decline an invitation.""" invitation = await Invitation.get(invitation_id, fetch_links=True) if invitation is None: @@ -283,7 +283,7 @@ async def decline_invitation(invitation_id: PydanticObjectId, user: CurrentUserD invitation.status = "declined" invitation.responded_at = datetime.now(tz=UTC) - _ = await invitation.save() + _ = await invitation.replace() # Send back a notification to the invitor about the decline notification = Notification( @@ -295,7 +295,7 @@ async def decline_invitation(invitation_id: PydanticObjectId, user: CurrentUserD ) notification = await notification.create() - return Response(status_code=status.HTTP_204_NO_CONTENT) + return InvitationData.from_invitation(invitation) router = APIRouter()