fix(backend): filter out DONE/CANCELED waitlists before sending notifications

The notify_waitlist_users_on_launch function was not filtering by
waitlist status, which could cause duplicate notifications when an
agent is re-approved. Now excludes DONE and CANCELED waitlists,
consistent with get_waitlist() and add_user_to_waitlist().

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Nicholas Tindle
2026-01-15 14:41:37 -06:00
parent 29a232fcb4
commit 205b220e90

View File

@@ -2438,17 +2438,24 @@ async def notify_waitlist_users_on_launch(
logger.info(f"Notifying waitlist users for store listing {store_listing_id}")
try:
# Find all waitlists linked to this store listing
# Find all active waitlists linked to this store listing
# Exclude DONE and CANCELED to prevent duplicate notifications on re-approval
waitlists = await prisma.models.WaitlistEntry.prisma().find_many(
where={
"storeListingId": store_listing_id,
"isDeleted": False,
"status": {
"not_in": [
prisma.enums.WaitlistExternalStatus.DONE,
prisma.enums.WaitlistExternalStatus.CANCELED,
]
},
},
include={"joinedUsers": True},
)
if not waitlists:
logger.info(f"No waitlists found for store listing {store_listing_id}")
logger.info(f"No active waitlists found for store listing {store_listing_id}")
return 0
notification_count = 0