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

fix: Embed Plus Org - Adds missing embed route, also fixes infinite redirection for migrated user in embed #12071

Merged
merged 5 commits into from
Oct 26, 2023

Conversation

hariombalhara
Copy link
Member

@hariombalhara hariombalhara commented Oct 25, 2023

What does this PR do?

  • Fixes infinite redirect in embed for migrated users
    • Also, fixes existing query params not being forwarded.
  • Fixes never implemented /embed route for Org user profile page.

Added unit tests as well for the two important functions involved here.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

  • Try visiting calcom.cal.local:3000/{ORG_USER}/embed - It was earlier giving 404
  • Migrate a user using /moveToOrg and open that user's old link app.cal.local:3000/{OLD_USER_NAME}/embed. It would go in infinite redirection

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't added tests that prove my fix is effective or that my feature works

@vercel
Copy link

vercel bot commented Oct 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai ❌ Failed (Inspect) Oct 26, 2023 3:53am
dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 26, 2023 3:53am
5 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api ⬜️ Ignored (Inspect) Visit Preview Oct 26, 2023 3:53am
cal ⬜️ Ignored (Inspect) Visit Preview Oct 26, 2023 3:53am
cal-demo ⬜️ Ignored (Inspect) Visit Preview Oct 26, 2023 3:53am
qa ⬜️ Ignored (Inspect) Visit Preview Oct 26, 2023 3:53am
ui ⬜️ Ignored (Inspect) Visit Preview Oct 26, 2023 3:53am

@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2023

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link to collect XP and win prizes!

@zomars zomars added the core area: core, team members only label Oct 25, 2023
@@ -15,10 +15,9 @@ export default function withEmbedSsr(getServerSideProps: GetServerSideProps) {
const destinationUrlObj = new URL(ssrResponse.redirect.destination, "https://base");

// Make sure that redirect happens to /embed page and pass on embed query param as is for preserving Cal JS API namespace
const newDestinationUrl = `${
const newDestinationUrl = `${destinationUrlObj.origin}${
Copy link
Member Author

Choose a reason for hiding this comment

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

With the recent redirect being on another domain, it is important to use the origin as well otherwise it causes infinite redirect.

Flow:
User Migrated to Org Redirect(to org domain) -> This embed redirect (Stays on org domain) -> On Org domain, no redirect needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

This caused an org member profile page to give 404 in embed.

@hariombalhara hariombalhara changed the title Add missing embed routes and fix infinite redirect for redirected links fix: Embed Plus Org - Adds missing embed route, also fixes infinite redirection Oct 25, 2023
@hariombalhara hariombalhara changed the title fix: Embed Plus Org - Adds missing embed route, also fixes infinite redirection fix: Embed Plus Org - Adds missing embed route, also fixes infinite redirection for migrated user in embed Oct 25, 2023
Copy link
Member Author

Choose a reason for hiding this comment

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

Missing routes, caused an org member profile page to give 404 in embed.

@hariombalhara hariombalhara added High priority Created by Linear-GitHub Sync organizations area: organizations, orgs labels Oct 25, 2023
@hariombalhara hariombalhara self-assigned this Oct 25, 2023
@hariombalhara hariombalhara marked this pull request as ready for review October 25, 2023 04:15
@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2023

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

New Page Added

The following page was added to the bundle from the code in this PR:

Page Size (compressed) First Load % of Budget (350 KB)
/org/[orgSlug]/[user]/embed 226.14 KB 382.25 KB 109.22%

@deploysentinel
Copy link

deploysentinel bot commented Oct 25, 2023

Current Playwright Test Results Summary

✅ 208 Passing - ⚠️ 2 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 10/26/2023 03:55:37am UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 96f6b88

Started: 10/26/2023 03:52:23am UTC

⚠️ Flakes

📄   packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Popup Tests should open embed iframe on click - Configured with light theme
Retry 1Initial Attempt
0.69% (2) 2 / 291 runs
failed over last 7 days
46.39% (135) 135 / 291 runs
flaked over last 7 days
Popup Tests should be able to reschedule
Retry 1Initial Attempt
8.62% (25) 25 / 290 runs
failed over last 7 days
88.62% (257) 257 / 290 runs
flaked over last 7 days

View Detailed Build Results


return {
redirect: {
permanent: false,
destination: eventTypeSlug ? `${redirect.toUrl}/${eventTypeSlug}` : redirect.toUrl,
destination: `${newDestination}${currentQueryString ? `?${currentQueryString}` : ""}`,
Copy link
Member Author

Choose a reason for hiding this comment

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

Current query params aren't automatically forwarded, so this does that.

Copy link
Contributor

@ThyMinimalDev ThyMinimalDev left a comment

Choose a reason for hiding this comment

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

LGTM

@hariombalhara hariombalhara merged commit bf8580f into main Oct 26, 2023
36 of 37 checks passed
@hariombalhara hariombalhara deleted the fix/embed-orgs branch October 26, 2023 08:12
hariombalhara added a commit that referenced this pull request Oct 27, 2023
hariombalhara added a commit that referenced this pull request Oct 27, 2023
hariombalhara added a commit that referenced this pull request Oct 27, 2023
hbjORbj pushed a commit to codemod-com/cal.com-demo that referenced this pull request Nov 28, 2023
hbjORbj pushed a commit to codemod-com/cal.com-demo that referenced this pull request Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core area: core, team members only High priority Created by Linear-GitHub Sync organizations area: organizations, orgs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants