Skip to content
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

chore: booking verification token and booking rejection logic from email #16324

Merged
merged 23 commits into from
Sep 21, 2024

Conversation

anikdhabal
Copy link
Contributor

@anikdhabal anikdhabal commented Aug 22, 2024

What does this PR do?

  • Fixes #XXXX (GitHub issue number)
  • Fixes CAL-XXXX (Linear issue number - should be visible at the bottom of the GitHub issue description)

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A-I have added a Docs issue here if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • N/A-I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

Copy link

vercel bot commented Aug 22, 2024

@anikdhabal is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@anikdhabal anikdhabal requested a review from zomars August 22, 2024 17:48
@github-actions github-actions bot added the ❗️ migrations contains migration files label Aug 22, 2024
@keithwillcode keithwillcode added the community-interns The team responsible for reviewing, testing and shipping low/medium community PRs label Aug 22, 2024
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Aug 22, 2024
@graphite-app graphite-app bot requested a review from a team August 22, 2024 17:48
@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking emails area: emails, cancellation email, reschedule email, inbox, spam folder, not getting email labels Aug 22, 2024
Copy link

graphite-app bot commented Aug 22, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (08/22/24)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (08/22/24)

1 label was added to this PR based on Keith Williams's automation.

Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @anikdhabal

Leaving some feedback to address.

I think we can simplify this even further.

I think naming the field oneTimePassword instead of bookingSecret is more intentional. Also booking.bookingSecret sounds redundant. We're are already in the booking model.

Using the authenticator library is overkill IMO. The token is random and secret enough and should be used as a disposable password anyways.

Just got the idea of testing then possibility of including a text field directly in the email to provide the rejection reason. Will test locally and keep you posted.

packages/prisma/schema.prisma Outdated Show resolved Hide resolved
packages/emails/src/templates/OrganizerRequestEmail.tsx Outdated Show resolved Hide resolved
packages/emails/src/templates/OrganizerRequestEmail.tsx Outdated Show resolved Hide resolved
packages/features/bookings/lib/handleNewBooking.ts Outdated Show resolved Hide resolved
packages/lib/test/builder.ts Outdated Show resolved Hide resolved
packages/types/Calendar.d.ts Outdated Show resolved Hide resolved
apps/web/pages/api/verify-booking-token.ts Outdated Show resolved Hide resolved
apps/web/pages/api/verify-booking-token.ts Outdated Show resolved Hide resolved
apps/web/pages/api/verify-booking-token.ts Outdated Show resolved Hide resolved
@anikdhabal
Copy link
Contributor Author

Thanks @zomars for the review, yes we can simply it. Fixed it

@anikdhabal anikdhabal requested a review from zomars August 23, 2024 04:07
<Separator />
<CallToAction
label={props.calEvent.organizer.language.translate("reject")}
// href={`${actionHref}&action=reject`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If omitted it will be a submit button for the form.

Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @anikdhabal made some changes. Can you verify if it's working properly?

@anikdhabal
Copy link
Contributor Author

Hey @anikdhabal made some changes. Can you verify if it's working properly?

Okay let me check

@anikdhabal
Copy link
Contributor Author

anikdhabal commented Aug 23, 2024

MailHog.and.16.more.pages.-.Personal.-.Microsoft.Edge.2024-08-23.11-19-34.mp4

@zomars the token value is currently undefined, that's why not working. Also, reason is not passed to the api and zoderror occured. Isn't using a redirect for the workflow better and more understandable than a direct submit?

Copy link
Contributor

github-actions bot commented Aug 23, 2024

E2E results are ready!

@@ -901,6 +901,7 @@ async function handler(
platformRescheduleUrl,
platformCancelUrl,
platformBookingUrl,
oneTimePassword: isConfirmedByDefault ? null : undefined,
Copy link
Contributor Author

@anikdhabal anikdhabal Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update the one-time password of calEvent after the booking, or we will get an undefined value in the email template. Currently, this is happening

Comment on lines 41 to 43
<textarea
placeholder="Why are you rejecting?"
style={{
Copy link
Contributor Author

@anikdhabal anikdhabal Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to set this field name to reason.

@anikdhabal
Copy link
Contributor Author

anikdhabal commented Aug 23, 2024

Screenshot 2024-08-23 123509
Screenshot 2024-08-23 123358

@zomars is this ok, I think redirecting to our booking canceled page would be better, just like before. What do you think?

@anikdhabal anikdhabal requested a review from zomars August 23, 2024 19:58
@anikdhabal
Copy link
Contributor Author

@zomars take a look whenever got a chance

@keithwillcode keithwillcode added this to the v4.6 milestone Sep 15, 2024
Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking to put a feature flag before merging #16038

Signed-off-by: zomars <zomars@me.com>

# Conflicts:
#	packages/emails/src/templates/OrganizerRequestEmail.tsx
Signed-off-by: zomars <zomars@me.com>
@@ -15,6 +15,7 @@ export { OrganizerCancelledEmail } from "./OrganizerCancelledEmail";
export { OrganizerLocationChangeEmail } from "./OrganizerLocationChangeEmail";
export { OrganizerPaymentRefundFailedEmail } from "./OrganizerPaymentRefundFailedEmail";
export { OrganizerRequestEmail } from "./OrganizerRequestEmail";
export { OrganizerRequestEmailV2 } from "./OrganizerRequestEmailV2";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a new template so we can enable it on demand @anikdhabal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great workaround @zomars 🚀

Signed-off-by: zomars <zomars@me.com>
Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made new tests and it's working flawlessly. Now we can also enable this for specific users and teams so we can test on multiple email clients before enabling globally. cc @emrysal @keithwillcode

Grabacion.de.pantalla.2024-09-20.a.la.s.17.32.29.mov

@zomars zomars enabled auto-merge (squash) September 21, 2024 00:36
@zomars zomars merged commit 1a60afa into calcom:main Sep 21, 2024
30 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bookings area: bookings, availability, timezones, double booking community Created by Linear-GitHub Sync community-interns The team responsible for reviewing, testing and shipping low/medium community PRs emails area: emails, cancellation email, reschedule email, inbox, spam folder, not getting email ❗️ migrations contains migration files ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants