Skip to content

Commit 77bd5fb

Browse files
committed
fix: Pass webhook body
1 parent 866e794 commit 77bd5fb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/handle-github-webhook.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ describe('handleGithubWebhook - unit tests', () => {
4343
});
4444

4545
it('should return status code from discord if the webhook was forwarded', async () => {
46-
nock('https://discord.com').get('/api/webhooks/12345/s3creTk3Y').reply(599);
46+
const payload = { sender: { login: 'kbkk' } };
4747

48-
const result = await handleGithubWebhook('/githubWebhook/s3creTk3Y', {});
48+
nock('https://discord.com').post('/api/webhooks/12345/s3creTk3Y', payload).reply(599);
49+
50+
const result = await handleGithubWebhook('/githubWebhook/s3creTk3Y', payload);
4951

5052
expect(result).to.eql({ statusCode: 599 });
5153
});

src/handle-github-webhook.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ async function handleGithubWebhook(
2727

2828
const discordWebhookUrl = getConfig('DISCORD_RECEIVE_GITHUB_WEBHOOK_URL');
2929

30-
const { status } = await fetch(discordWebhookUrl);
30+
const { status } = await fetch(discordWebhookUrl, {
31+
method: 'POST',
32+
body: JSON.stringify(body),
33+
});
3134

3235
return { statusCode: status };
3336
}

0 commit comments

Comments
 (0)