Skip to content

Commit 30c3648

Browse files
committed
Simplify sendWebhook function in github-filter worker
This previously wasn't working correctly, as it was forwarded the response on failure correctly. However, we had no need to create a new Response object, as returning the Discord response is fine in all cases. This simplifies the worker quite a lot.
1 parent dc51ea8 commit 30c3648

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

github-filter/src/index.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,8 @@ async function sendLabelWebhook(label: string, data: Data, labelNamespace: KVNam
128128
}
129129

130130
async function sendWebhook(id: string, token: string, data: Data) {
131-
// Format for a webhook
132-
let template = `https://discord.com/api/webhooks/${id}/${token}/github?wait=1`;
133-
134-
let new_request = new Request(template, {
135-
body: data.body,
136-
headers: data.headers,
137-
method: data.method,
138-
});
139-
140131
// Pass on data to Discord as usual
141-
const response = await fetch(template, new_request);
142-
if (!response.ok) {
143-
return new Response(await response.json(), {
144-
status: response.status,
145-
});
146-
}
147-
return response;
132+
return await fetch(`https://discord.com/api/webhooks/${id}/${token}/github?wait=1`, data);
148133
}
149134

150135
export default wrapModule(hcConfig, worker);

0 commit comments

Comments
 (0)