Add invited events endpoint
This commit is contained in:
parent
1eaef54d70
commit
f83f0d1ae1
|
@ -172,6 +172,23 @@ async def get_user_events(user_id: PydanticObjectId, user: CurrentUserDep) -> li
|
|||
return [EventData.from_event(event) for event in events]
|
||||
|
||||
|
||||
@base_router.get("/users/{user_id}/events/invited")
|
||||
async def get_user_invited_events(user_id: PydanticObjectId, user: CurrentUserDep) -> list[EventData]:
|
||||
"""Get all events that given user was invited to.
|
||||
|
||||
These are the events that the user has already accepted the invite for.
|
||||
Events pending acceptance are not included.
|
||||
"""
|
||||
if user_id != user.id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="You can only access your own invite categories",
|
||||
)
|
||||
|
||||
events = await (Event.find(expr(Event.attendees).id == user_id, fetch_links=True)).to_list()
|
||||
return [EventData.from_event(event) for event in events]
|
||||
|
||||
|
||||
@events_router.get("{event_id}")
|
||||
async def get_event(event_id: PydanticObjectId, user: CurrentUserDep) -> EventData:
|
||||
"""Get an event by ID."""
|
||||
|
|
Loading…
Reference in a new issue