{"record":{"id":"6b038c9b14950612","repo":"koala73/worldmonitor","slug":"invite-already-used","errorCode":"INVITE_ALREADY_USED","errorMessage":"INVITE_ALREADY_USED","messagePattern":"INVITE_ALREADY_USED","errorType":"error_code","errorClass":"ConvexError","httpStatus":null,"severity":"error","filePath":"convex/payments/businessSeats.ts","lineNumber":464,"sourceCode":" * grant to `accepted`, stamps `inviteeUserId`, and recomputes the invitee's\n * entitlement. Single-use: accepted/revoked/expired tokens are rejected.\n */\nexport const acceptBusinessInvite = mutation({\n  args: { grantId: v.id(\"businessProGrants\"), token: v.string() },\n  handler: async (ctx, args) => {\n    const userId = await requireUserId(ctx);\n    const identity = await resolveUserIdentity(ctx);\n    const inviteeEmail = identity?.email?.trim().toLowerCase();\n    if (!inviteeEmail) {\n      throw new ConvexError({ kind: \"INVITEE_EMAIL_UNAVAILABLE\" });\n    }\n\n    const grant = await ctx.db.get(args.grantId);\n    if (!grant) {\n      throw new ConvexError({ kind: \"GRANT_NOT_FOUND\" });\n    }\n    if (grant.status !== \"pending\") {\n      throw new ConvexError({ kind: \"INVITE_ALREADY_USED\" });\n    }\n    const now = Date.now();\n    if (grant.expiresAt <= now) {\n      throw new ConvexError({ kind: \"INVITE_EXPIRED\" });\n    }\n    if (!(await verifyBusinessInviteToken(args.grantId, args.token))) {\n      throw new ConvexError({ kind: \"INVALID_INVITE_TOKEN\" });\n    }\n    if (grant.inviteeEmail !== inviteeEmail) {\n      throw new ConvexError({ kind: \"INVITE_EMAIL_MISMATCH\" });\n    }\n    if (!sameDomain(grant.inviteeEmail, inviteeEmail)) {\n      throw new ConvexError({ kind: \"INVITE_EMAIL_MISMATCH\" });\n    }\n    if (!isCorporateDomain(inviteeEmail)) {\n      throw new ConvexError({ kind: \"INVITEE_DOMAIN_NOT_CORPORATE\" });\n    }\n","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/koala73/worldmonitor/blob/7d06c8633d256c18e38133030bc3613976a96ec9/convex/payments/businessSeats.ts#L446-L482","documentation":"Structured ConvexError thrown by acceptBusinessInvite when the referenced grant's status is not pending — i.e. the single-use invite was already accepted or revoked. Redeeming a used invite token is rejected by design.","triggerScenarios":"Thrown at convex/payments/businessSeats.ts:468 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["If already accepted, no action is needed — entitlement is already granted","Otherwise request a fresh invite from the Business owner"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d06c8633d256c18e38133030bc3613976a96ec9","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}