commit e024eb8492b0fab97a4bdbf8ab9c48ddf35cec50
parent 5a3c6d5fb736983c745533defea4294ece9b532d
Author: Amit Dutta <mail@amit.is-a.dev>
Date: Fri, 17 Jul 2026 20:38:04 +0530
chore: refactor webhook logic for pull request feedback (#77)
* Refactor webhook logic for pull request feedback
Refactor timeout logic and enhance PR denial messages.
* Update src/webhooks/labeled.js
Co-authored-by: iostpa <iostpa@proton.me>
* Apply suggestion from @notamitgamer
* Refactor denied and invalid pull request handling
Refactor conditional statements for denied and invalid pull requests to improve readability.
---------
Co-authored-by: iostpa <iostpa@proton.me>
Diffstat:
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/webhooks/labeled.js b/src/webhooks/labeled.js
@@ -49,7 +49,7 @@ export async function labeled(
if (denied === true || invalid === true) {
const listOfLabels = [];
// timeout so that it creates a little time window for the maintainer to add the rest of the labels
- await new Promise((resolve) => setTimeout(resolve, 5000));
+ await new Promise((resolve) => setTimeout(resolve, 3000));
const data = await appOctokit.request(
'GET /repos/{owner}/{repo}/pulls/{pull_number}',
{
@@ -100,7 +100,21 @@ export async function labeled(
path.join(import.meta.dirname, `../message/invalidnolabel.md`),
'utf8'
);
- } else {
+ } else if (denied) {
+ body = `
+# Pull Request Denied
+
+This pull request has been denied due to the following reason(s):
+
+---
+${labelMessages}
+
+---
+
+If you believe this was a mistake, or if you need further clarification, please feel free to create an issue or reach out to our team in the [Discord server](https://discord.gg/is-a-dev-830872854677422150).
+
+`;
+ } else if (invalid) {
body = `
# Invalid Pull Request