Actually add the user as attendee on accepted invite

This commit is contained in:
Peter Vacho 2024-12-29 14:59:49 +01:00
parent fcf5a5d64d
commit 6c9afdbdeb
Signed by: school
GPG key ID: 8CFC3837052871B4

View file

@ -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,