feat(invite): Referral system with Email/SMS/WhatsApp invites #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements a referral/invite system allowing users to invite friends via Email (SendGrid), SMS (Twilio), or WhatsApp (Twilio).
Key Changes:
createInviteandredeemInviteinvitePreview(unauthenticated)inviteById,invitesListHow It Works
createInvitewith contact (email/phone) + method (EMAIL/SMS/WHATSAPP)redeemInvitewith tokenFiles Changed (37 files, +2117/-111)
Core Implementation:
src/app/invite/- Invite creation, redemption, rate limitingsrc/domain/invite/- Domain types and validationsrc/graphql/public/root/mutation/create-invite.ts- Create invite mutationsrc/graphql/public/root/mutation/redeem-invite.ts- Redeem invite mutationsrc/graphql/public/root/query/invite-preview.ts- Preview invite querysrc/services/mongoose/models/invite.ts- MongoDB schemasrc/services/notification/index.ts- Twilio/SendGrid notification servicesrc/services/notifications/invite.ts- Invite-specific notificationsAdmin Features:
src/app/admin/invite.ts- Revoke, extend, reset rate limitssrc/graphql/admin/root/query/invite-by-id.ts- View invite detailssrc/graphql/admin/root/query/invites-list.ts- List/filter invitesKnown Issues / Follow-up Tickets
🔴 HIGH PRIORITY
Dead Code / Duplicate Logic
src/app/invite/redeem-invite.tsvssrc/graphql/public/root/mutation/redeem-invite.tssrc/app/invite/redeem-invite.ts(60 lines) appears unused.src/app/invite/redeem-invite.tsor refactor mutation to use itToken Fragment Logged
src/graphql/public/root/mutation/redeem-invite.tsline 156🟡 MEDIUM PRIORITY
Email Validation Deferred (Documented in code)
src/graphql/public/root/mutation/redeem-invite.tslines 115-127Type Casting Hack in Rate Limits
src/app/invite/rate-limits.tsline 21keyToConsume: contact as IpAddress- incorrect type castWhatsApp Template Handling Incomplete
src/services/notification/index.tslines 176-189TWILIO_WHATSAPP_TEMPLATE_SIDenv var but not in schemaNo Transaction Boundary for Multi-Step Operations
src/graphql/public/root/mutation/redeem-invite.tslines 128-132Status Transition Edge Case
src/app/admin/invite.tsline 61🟢 LOW PRIORITY
complexity: 120without documentationhttps://getflash.iofallback in notificationsPre-existing Test Infrastructure Issues
Same issues as PR #212 (feat/email-registration):
IdentityState→IdentityStateEnumin Kratos servicelnurlpin Wallet mocks,npubin Account mocksaddInvoiceForSelfForBtcWalletremoved, test files need updatesFractionalCentAmounttype mismatchesThese should be fixed once and shared across feature branches.
Testing
yarn tsc --noEmit- only pre-existing test errors)Checklist