-
Notifications
You must be signed in to change notification settings - Fork 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
fix: body payload of MEETING_STARTED & MEETING_ENDED webhook #15036
Conversation
@hussamkhatib is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link. |
Graphite Automations"Add community label" took an action on this PR • (05/14/24)1 label was added to this PR based on Keith Williams's automation. "Add consumer team as reviewer" took an action on this PR • (05/14/24)1 reviewer was added to this PR based on Keith Williams's automation. |
📦 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! 🙌 |
packages/features/webhooks/lib/handleWebhookScheduledTriggers.ts
Outdated
Show resolved
Hide resolved
The unit tests are failling |
d8cac17
to
9f45c2e
Compare
@@ -295,8 +295,6 @@ export function expectWebhookToHaveBeenCalledWith( | |||
} | |||
if (data.payload.responses !== undefined) | |||
expect(parsedBody.payload.responses).toEqual(expect.objectContaining(data.payload.responses)); | |||
const { responses: _1, metadata: _2, ...remainingPayload } = data.payload; | |||
expect(parsedBody.payload).toEqual(expect.objectContaining(remainingPayload)); |
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.
Compare the 2 snippets at the end of the Issue for why this is not needed.
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.
I’ve added some comments. I’m also concerned that these changes will break existing workflows for users, as fields won't be accessible anymore as they used to
@@ -295,8 +295,6 @@ export function expectWebhookToHaveBeenCalledWith( | |||
} | |||
if (data.payload.responses !== undefined) | |||
expect(parsedBody.payload.responses).toEqual(expect.objectContaining(data.payload.responses)); | |||
const { responses: _1, metadata: _2, ...remainingPayload } = data.payload; | |||
expect(parsedBody.payload).toEqual(expect.objectContaining(remainingPayload)); |
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.
let's fix the test instead of deleting it, this function is also used for other tests were it passes
To make sure we don't break existing workflows for users, we decided to keep all fields as they are right now but additionally add the missing fields |
Sounds good @CarinaWolli, So could I go ahead without using |
Yes we can do that for now 👍 |
14acdc8
to
a00bede
Compare
a00bede
to
4053f66
Compare
/bonus 20 @hussamkhatib would you be down to look into the merge conflict? |
A bonus of $20 has been added by PeerRich. |
@hussamkhatib care to give more details on why a migration is need in the first place? What are the actual differences between payload and legacyPayload? Both system and DB wise. |
const { booking: bookingWithWebhookPayload, evt } = await getBooking(booking.id); | ||
const webhookData = getWebhookPayloadForBooking({ | ||
booking: bookingWithWebhookPayload, | ||
evt, | ||
}); |
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.
Can we move the fetching of the booking and creation of the webhookData
outside addedEventTriggers.map
?
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.
Sure, thanks for catching that.
8c8379a
to
d32306e
Compare
…ide addedEventTriggers.map
You can find example of legacy payload and payload below. Compare the responses Object below, the legacy payload has a flatter Object compared to what's shown in the docs After this change user should receive payload in the below format
Example of legacy payload
Example of payload
|
This PR is being marked as stale due to inactivity. |
@hussamkhatib could you pls fix the conflict |
Closing due to staleness. |
What does this PR do?
The PR now provides the proper body in the webhook payload for scheduled Triggers (MEETING_STARTED & MEETING_ENDED)
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Follow steps to setup webhooks in your applciation from the docs
Adding logs to print (
req.body.payload, req.body
)Trigger the MEETING_START or MEETING_ENDED event
You should find
req.body.payload
will beundefined
andreq.body
having the contents of payload which isn't the format mentioned in the docs, neither do other events have.What are the minimal test data to have?
Booking a event creates the necessary records in the database, for ease of testing set buffer time to book to 0 and booking interval to 1 min, so that MEETING_STARTED & MEETING_ENDED will be trigerred faster.
Checklist