diff --git a/src/api/invitations.py b/src/api/invitations.py index 94110af..b05e79f 100644 --- a/src/api/invitations.py +++ b/src/api/invitations.py @@ -228,10 +228,19 @@ async def accept_invitation(invitation_id: PydanticObjectId, user: CurrentUserDe detail="You can only accept pending invitations.", ) + # Mark the invitation as accepted invitation.status = "accepted" invitation.responded_at = datetime.now(tz=UTC) _ = await invitation.save() + # Add the user to the event + event = invitation.event + if isinstance(event, Link): + raise UnfetchedLinkError(event) + + event.attendees.append(invitation.invitee) + event = await event.replace() + # Send back a notification to the invitor about the acceptance notification = Notification( user=invitation.invitor,