Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions app/core/tickets/endpoints_tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from app.core.memberships import utils_memberships
from app.core.mypayment import cruds_mypayment, schemas_mypayment, utils_mypayment
from app.core.mypayment.mypayment_tool import MyPaymentTool
from app.core.notification.schemas_notification import Message
from app.core.permissions.type_permissions import ModulePermissions
from app.core.tickets import cruds_tickets, schemas_tickets, utils_tickets
from app.core.tickets.factory_tickets import TicketsFactory
Expand Down Expand Up @@ -456,6 +457,7 @@ async def ticket_accept_change_over(
token: str,
db: AsyncSession = Depends(get_db),
settings: Settings = Depends(get_settings),
notification_tool: NotificationTool = Depends(get_notification_tool),
):
"""
Accept a ticket transfer invitation. The user will become the new owner of the ticket.
Expand All @@ -473,6 +475,21 @@ async def ticket_accept_change_over(
),
)

ticket = await cruds_tickets.get_ticket_by_id(
ticket_id=invitation.ticket_id,
db=db,
)
if ticket is None:
raise ObjectExpectedInDbNotFoundError("ticket", invitation.ticket_id)
event = await cruds_tickets.get_event_simple_by_id(
event_id=ticket.event_id,
db=db,
)
if event is None:
raise ObjectExpectedInDbNotFoundError("event", ticket.event_id)

previous_user_id = ticket.user_id

await cruds_tickets.delete_ticket_change_over_invitation(
ticket_id=invitation.ticket_id,
db=db,
Expand All @@ -484,6 +501,26 @@ async def ticket_accept_change_over(
db=db,
)

message = Message(
title="🎟️ Transfert de ticket accepté",
content=f"La demande de transfert de ticket pour l'événement {event.name} a été acceptée",
action_module="loan",
)
await notification_tool.send_notification_to_user(
user_id=previous_user_id,
message=message,
)

message = Message(
title="🎟️ Ticket transféré",
content=f"Tu viens d'accepter un ticket pour l'événement {event.name}",
action_module="loan",
)
await notification_tool.send_notification_to_user(
user_id=invitation.new_user_id,
message=message,
)

Comment thread
armanddidierjean marked this conversation as resolved.
return RedirectResponse(
url=settings.CLIENT_URL
+ calypsso.get_message_relative_url(
Expand Down
Loading