Skip to content

Commit

Permalink
chore: use user_id in ics route instead of telegram id
Browse files Browse the repository at this point in the history
  • Loading branch information
dantetemplar committed Sep 28, 2024
1 parent e74cab7 commit 2d7e83b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/api/root/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from src.api.dependencies import VerifiedDep
from src.exceptions import ForbiddenException
from src.repositories.bookings.repository import booking_repository
from src.repositories.users.repository import user_repository
from src.schemas.auth import VerificationSource

router = APIRouter(tags=["Root"])
Expand Down Expand Up @@ -47,7 +46,7 @@ def _booking_to_vevent(booking, is_personal=False):


@router.get(
"/users/by-telegram/{telegram_id}/bookings.ics",
"/users/{user_id}/bookings.ics",
responses={
200: {
"description": "ICS file with schedule of the user",
Expand All @@ -57,12 +56,11 @@ def _booking_to_vevent(booking, is_personal=False):
response_class=Response,
tags=["Users", "ICS"],
)
async def get_user_ics(telegram_id: int, verification: VerifiedDep):
if verification.source == VerificationSource.BOT and telegram_id != verification.telegram_id:
async def get_user_ics(user_id: int, verification: VerifiedDep):
if verification.source == VerificationSource.BOT and user_id != verification.telegram_id:
raise ForbiddenException()

main_calendar = _calendar_baseline()
user_id = await user_repository.get_user_id(telegram_id=telegram_id)
bookings = await booking_repository.get_user_bookings(user_id)
dtstamp = icalendar.vDatetime(datetime.datetime.now())
for booking in bookings:
Expand Down

0 comments on commit 2d7e83b

Please sign in to comment.