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

feat: Delete/Create WebhookScheduledTriggers for existing bookings #14121

Conversation

Amit91848
Copy link
Contributor

What does this PR do?

Fixes #14103

Screen.Recording.2024-03-17.at.4.04.39.PM.mov

Type of change

  • New feature (non-breaking change which adds functionality)

Mandatory Tasks

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

Copy link

vercel bot commented Mar 17, 2024

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

A member of the Team first needs to authorize it.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Mar 17, 2024
@graphite-app graphite-app bot requested a review from a team March 17, 2024 10:46
@CLAassistant
Copy link

CLAassistant commented Mar 17, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

github-actions bot commented Mar 17, 2024

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

@github-actions github-actions bot added webhooks area: webhooks, callback, webhook payload 🐛 bug Something isn't working labels Mar 17, 2024
Copy link

graphite-app bot commented Mar 17, 2024

Graphite Automations

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

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

"Add community label" took an action on this PR • (03/17/24)

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

Copy link
Contributor

github-actions bot commented Mar 17, 2024

📦 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! 🙌

@CarinaWolli CarinaWolli added this to the v4.0 milestone Mar 19, 2024
Copy link
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.

Great start already, but we also need to handle account wide webhooks from http://localhost:3000/settings/developer/webhooks. Right now this only takes care of event type specific webhooks.

I have a PR open that adds a relationship between WebhooksScheduledTriggers and Webhook, which probably would make it easier to find the jobs we need to cancel #14188


if (
removedEventTriggers.length > 0 &&
removedEventTriggers.some((trigger) => SCHEDULING_TRIGGER.includes(trigger))
Copy link
Member

Choose a reason for hiding this comment

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

removedEventTriggers.some((trigger) => SCHEDULING_TRIGGER.includes(trigger))

Why do we need that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot to remove it from here.

(trigger) => !updatedEventTriggers.includes(trigger) && SCHEDULING_TRIGGER.includes(trigger)
);
const currentTime = new Date();
const bookings = await prisma.booking.findMany({
Copy link
Member

Choose a reason for hiding this comment

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

let's early return before that if there are no added or removed triggers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

);
const currentTime = new Date();
const bookings = await prisma.booking.findMany({
where: {
Copy link
Member

Choose a reason for hiding this comment

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

can already query for only ACCEPTED bookings here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah right, slipped my mind 😅

@Amit91848
Copy link
Contributor Author

Great start already, but we also need to handle account wide webhooks from http://localhost:3000/settings/developer/webhooks. Right now this only takes care of event type specific webhooks.

I have a PR open that adds a relationship between WebhooksScheduledTriggers and Webhook, which probably would make it easier to find the jobs we need to cancel #14188

Will make other changes till your pr is merged.

@Amit91848
Copy link
Contributor Author

@CarinaWolli Now this works for account wide webhooks too.

Copy link
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, tested and works 🙌🏻 Thank you 🙏

@CarinaWolli CarinaWolli enabled auto-merge (squash) April 12, 2024 16:51
@CarinaWolli CarinaWolli merged commit 5561949 into calcom:main Apr 12, 2024
30 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working community 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-3278] Delete/Create WebhookScheduledTriggers for existing bookings
5 participants