Skip to content

feat: add utcOffset in webhook payload#12709

Merged
keithwillcode merged 17 commits intocalcom:mainfrom
jkcs:feat/add_UTCOffset
Jan 11, 2024
Merged

feat: add utcOffset in webhook payload#12709
keithwillcode merged 17 commits intocalcom:mainfrom
jkcs:feat/add_UTCOffset

Conversation

@jkcs
Copy link
Copy Markdown
Contributor

@jkcs jkcs commented Dec 8, 2023

What does this PR do?

Fixes #12415
/claim #12415

Requirement/Documentation

  • If there is a requirement document, please, share it here.
  • If there is ab UI/UX design document, please, share it here.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Mandatory Tasks

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

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 8, 2023

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

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 8, 2023

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

@github-actions github-actions bot added api area: API, enterprise API, access token, OAuth Medium priority Created by Linear-GitHub Sync webhooks area: webhooks, callback, webhook payload ✨ feature New feature or request 💎 Bounty A bounty on Algora.io labels Dec 8, 2023
@jkcs jkcs changed the title add utcOffset in webhook feat: add utcOffset in webhook Dec 8, 2023
@jkcs jkcs marked this pull request as draft December 8, 2023 11:00
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 8, 2023

📦 Next.js Bundle Analysis for @calcom/web

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

This PR introduced no changes to the JavaScript bundle! 🙌

@jkcs jkcs changed the title feat: add utcOffset in webhook feat: add utcOffset in webhook data Dec 10, 2023
@jkcs jkcs changed the title feat: add utcOffset in webhook data feat: add utcOffset in webhook payload Dec 10, 2023
@jkcs jkcs marked this pull request as ready for review December 10, 2023 10:01
@CarinaWolli CarinaWolli requested a review from a team December 12, 2023 21:01
Copy link
Copy Markdown
Member

@CarinaWolli CarinaWolli 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 contributing 🙏 Left you one comment, everything else looks good

if (!timeZone) return null;

if (timeZoneWithDST(timeZone)) {
return getUTCOffsetInDST(timeZone);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wouldn't this now always return DST offset of this timezone, even when we are not in DST like now in December?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wow, you reminded me so well. I was overthinking it. This is not necessary.

export function getUTCOffsetByTimezone(timeZone: string) {
if (!timeZone) return null;

return dayjs().tz(timeZone).utcOffset();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But we still do need to take care of DST here.

This should work if we add another parameter to the function for the date:
dayjs(date).tz(timeZone).utcOffset()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@jkcs
Copy link
Copy Markdown
Contributor Author

jkcs commented Dec 21, 2023

Hello, @Shpadoinkle . I suggest that you open a new issue. The changes in this pull request only include the modification mentioned in #12415 "Add the attendee UTC offset as a field, rather than the string of the timezone." As for the issue you mentioned, I think it's worth addressing as well.

@Shpadoinkle
Copy link
Copy Markdown
Contributor

Shpadoinkle commented Dec 21, 2023

@jkcs ah ignore me all together, the timeZone string was already on the webhook

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 5, 2024

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Jan 5, 2024
@CarinaWolli CarinaWolli self-requested a review January 8, 2024 15:35
@github-actions github-actions bot removed the Stale label Jan 9, 2024
data: Omit<WebhookDataType, "createdAt" | "triggerEvent">
): WithUTCOffsetType<WebhookDataType> {
if (data.organizer?.timeZone) {
(data.organizer as Person & UTCOffset).utcOffset = getUTCOffsetByTimezone(data.organizer.timeZone);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we are missing the date parameter here (data.startTime), otherwise, we will always get the utc offset from the current date (important for DST)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


if (data?.attendees?.length) {
(data.attendees as (Person & UTCOffset)[]).forEach((attendee) => {
attendee.utcOffset = getUTCOffsetByTimezone(attendee.timeZone);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@jkcs jkcs requested a review from CarinaWolli January 10, 2024 06:10
Copy link
Copy Markdown
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

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

Looks good now 👍 Thank you for your contribution 🙏

@keithwillcode keithwillcode enabled auto-merge (squash) January 10, 2024 15:43
@keithwillcode keithwillcode added this to the v3.7 milestone Jan 10, 2024
@github-actions github-actions bot added the linear Sync Github Issue from community members to Linear.app label Jan 11, 2024
@keithwillcode keithwillcode merged commit 026f22f into calcom:main Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api area: API, enterprise API, access token, OAuth 🙋 Bounty claim 💎 Bounty A bounty on Algora.io ✨ feature New feature or request linear Sync Github Issue from community members to Linear.app Medium priority Created by Linear-GitHub Sync webhooks area: webhooks, callback, webhook payload

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-2904] Request to add 2 Fields to Webhook Payloads

5 participants