-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: invite members handler #12442
Conversation
CAL-2698 Refactor InviteMember handler
file: packages/trpc/server/routers/viewer/teams/inviteMember/inviteMember.handler.ts Currently inviteMember allows bulk invite of team members, which can be overloading our database very quickly the problems are the following:
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
5 Ignored Deployments
|
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link to collect XP and win prizes! |
25e43a4
to
d0e6d34
Compare
packages/trpc/server/routers/viewer/teams/inviteMember/utils.ts
Outdated
Show resolved
Hide resolved
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
Current Playwright Test Results Summary✅ 38 Passing - Run may still be in progress, this comment will be updated as current testing workflow or job completes... (Last updated on 11/27/2023 08:20:51am UTC) Run DetailsRunning Workflow PR Update on Github Actions Commit: c9bf49e Started: 11/27/2023 08:19:42am UTC
|
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
FORM_SUBMITTED on submitting team form, triggers team webhook
Retry 1 • Initial Attempt |
3.47% (9)9 / 259 runsfailed over last 7 days |
17.37% (45)45 / 259 runsflaked over last 7 days |
packages/trpc/server/routers/viewer/teams/inviteMember/utils.ts
Outdated
Show resolved
Hide resolved
teams: { | ||
create: { | ||
teamId: input.teamId, | ||
role: input.role as MembershipRole, | ||
accepted: autoAccept, // If the user is invited to a child team, they are automatically accepted | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could conditionally create the membership to the Organization here instead of doing it in the if parentId statement
below, but it would not have any impact since prisma would still make different sql queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Tested locally - tests cover pretty much all edge cases we need
much much faster when testing locally compared to main (like take a look at the difference its crazy )
* refactor: invite members handler * fixup! refactor: invite members handler * fixup! fixup! refactor: invite members handler * refactor: promise all settled send emails * fixup! refactor: promise all settled send emails * fixup! fixup! refactor: promise all settled send emails * fixup! fixup! fixup! refactor: promise all settled send emails * fix: opening team invite link in email throws error on signup page * fixup! Merge branch 'main' into cal-2698-refactor-invitemember-handler * fix: centralize validation if invitee can be invited * fix: improve select query and fix tests * fixup! Merge branch 'main' into cal-2698-refactor-invitemember-handler * rename functions and add some tests
* refactor: invite members handler * fixup! refactor: invite members handler * fixup! fixup! refactor: invite members handler * refactor: promise all settled send emails * fixup! refactor: promise all settled send emails * fixup! fixup! refactor: promise all settled send emails * fixup! fixup! fixup! refactor: promise all settled send emails * fix: opening team invite link in email throws error on signup page * fixup! Merge branch 'main' into cal-2698-refactor-invitemember-handler * fix: centralize validation if invitee can be invited * fix: improve select query and fix tests * fixup! Merge branch 'main' into cal-2698-refactor-invitemember-handler * rename functions and add some tests
What does this PR do?
Refactor trpc invite handler to treat the operations as batches
Type of change
How should this be tested?
Mandatory Tasks
Checklist