Skip to content

[Backend] Complete Party Invitation and Acceptance Flow#384

Open
zhero-o wants to merge 2 commits into
StayLitCodes:mainfrom
zhero-o:main
Open

[Backend] Complete Party Invitation and Acceptance Flow#384
zhero-o wants to merge 2 commits into
StayLitCodes:mainfrom
zhero-o:main

Conversation

@zhero-o
Copy link
Copy Markdown
Contributor

@zhero-o zhero-o commented Jun 2, 2026

Summary

Closes #274

Changes

New endpoints

Method Path Description
POST /escrows/:id/parties/:partyId/accept Accept a party invitation. Sets status to ACCEPTED, records respondedAt, logs event, notifies escrow creator.
POST /escrows/:id/parties/:partyId/reject Reject a party invitation. Auto-cancels escrow if a required party (buyer/seller) rejects. Notifies creator.
GET /escrows/pending-invitations List all escrows where the authenticated user has a PENDING party invitation.

Rules enforced

  • Only the user matching party.userId can accept or reject their own invitation
  • Invitations can only be responded to once (idempotency guard)
  • fund() now blocks with a 400 if any buyer or seller party hasn't accepted
  • A required party (buyer/seller) rejecting a PENDING escrow automatically cancels it

Other changes

  • PARTY_INVITED, PARTY_ACCEPTED, PARTY_REJECTED added to NotificationEventType
  • Email templates added for all three notification events
  • respondedAt: Date | null column added to Party entity
  • Migration 1780300000000-AddRespondedAtToParty adds the column
  • NotificationsModule imported into EscrowModule
  • Unit tests for accept, reject, pending invitations, and funding gate

Test plan

  • Create escrow → each invited party receives PARTY_INVITED notification
  • POST /parties/:partyId/accept as correct user → status becomes ACCEPTED
  • POST /parties/:partyId/accept as wrong user → 403
  • POST /parties/:partyId/accept twice → 400
  • POST /parties/:partyId/reject by seller → escrow auto-cancels, creator notified
  • GET /escrows/pending-invitations → returns only PENDING invitations for current user
  • Fund escrow with unaccepted seller → 400 error
  • Fund escrow after all parties accept → succeeds

zhero-o added 2 commits June 2, 2026 11:43
- POST /escrows/:id/parties/:partyId/accept — sets status to ACCEPTED,
  records respondedAt, logs PARTY_ACCEPTED event, notifies escrow creator
- POST /escrows/:id/parties/:partyId/reject — sets status to REJECTED,
  auto-cancels escrow when a required party (buyer/seller) rejects,
  notifies escrow creator
- GET /escrows/pending-invitations — lists escrows with PENDING party
  invitations for the authenticated user
- fund() now gates on all buyer+seller parties having ACCEPTED status
- PARTY_INVITED notification dispatched for each invited party on escrow creation
- Add PARTY_INVITED, PARTY_ACCEPTED, PARTY_REJECTED to NotificationEventType enum
- Add email templates for new notification events
- Add respondedAt column to Party entity + migration
- Import NotificationsModule into EscrowModule
- Unit tests for accept, reject, getPendingInvitations, and fund gate

Closes StayLitCodes#274
[Backend] Complete Party Invitation and Acceptance Flow
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 2, 2026

@zhero-o Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] Complete Party Invitation and Acceptance Flow

1 participant