Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/odd-beds-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes an issue that caused Hono to not process payloads with content type `x-www-form-urlencoded` correctly
3 changes: 3 additions & 0 deletions apps/meteor/app/api/server/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ export class Router<
parsedBody = await request.raw.clone().json();
} else if (contentType?.includes('multipart/form-data')) {
parsedBody = await request.raw.clone().formData();
} else if (contentType?.includes('application/x-www-form-urlencoded')) {
const req = await request.raw.clone().formData();
parsedBody = Object.fromEntries(req.entries());
} else {
parsedBody = await request.raw.clone().text();
}
Expand Down
24 changes: 5 additions & 19 deletions apps/meteor/tests/end-to-end/api/livechat/06-integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,14 @@ describe('LIVECHAT - Integrations', () => {
return Promise.all(visitorTokens.map((token) => deleteVisitor(token)));
});

// Twilio sends the body as a x-www-form-urlencoded, the tests should do the same
describe('POST livechat/sms-incoming/:service', () => {
it('should throw an error if SMS is disabled', async () => {
await updateSetting('SMS_Enabled', false);
await request
.post(api('livechat/sms-incoming/twilio'))
.set(credentials)
.send({
from: '+123456789',
body: 'Hello',
})
.send('from=%2B123456789&body=Hello')
.expect('Content-Type', 'application/json')
.expect(400);
});
Expand All @@ -82,11 +80,7 @@ describe('LIVECHAT - Integrations', () => {
await request
.post(api('livechat/sms-incoming/twilio'))
.set(credentials)
.send({
From: '+123456789',
To: '+123456789',
Body: 'Hello',
})
.send('From=%2B123456789&To=%2B123456789&Body=Hello')
.expect('Content-Type', 'application/json')
.expect(400);
});
Expand All @@ -97,11 +91,7 @@ describe('LIVECHAT - Integrations', () => {
await request
.post(api('livechat/sms-incoming/twilio'))
.set(credentials)
.send({
From: '+123456789',
To: '+123456789',
Body: 'Hello',
})
.send('From=%2B123456789&To=%2B123456789&Body=Hello')
.expect('Content-Type', 'application/json')
.expect(400);
});
Expand All @@ -113,11 +103,7 @@ describe('LIVECHAT - Integrations', () => {
await request
.post(api('livechat/sms-incoming/twilio'))
.set(credentials)
.send({
From: '+123456789',
To: '+123456789',
Body: 'Hello',
})
.send('From=%2B123456789&To=%2B123456789&Body=Hello')
.expect('Content-Type', 'text/xml')
.expect(200)
.expect((res: Response) => {
Expand Down
Loading