From b9ce7c7fd403dc35ac052f34664e2e0ceda92aaf Mon Sep 17 00:00:00 2001 From: shiftinv Date: Sat, 3 Sep 2022 02:39:36 +0200 Subject: [PATCH] feat: filter more events --- lib/filter.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/filter.ts b/lib/filter.ts index b10cf95..04bd898 100644 --- a/lib/filter.ts +++ b/lib/filter.ts @@ -1,7 +1,25 @@ import { UrlConfig } from "./types.d.ts"; export default function filter(headers: Headers, json: any, config: UrlConfig): string | null { - const event = headers.get("x-github-event"); + const event = headers.get("x-github-event") || "unknown"; + if (["status", "pull_request_review_thread"].includes(event)) { + return event; + } + + if ( + event === "pull_request" && json.action && + !["opened", "closed", "reopened"].includes(json.action) + ) { + return "no-op PR event"; + } + + if ( + event === "issues" && json.action && + !["opened", "deleted", "closed", "reopened", "transferred"].includes(json.action) + ) { + return "no-op issue event"; + } + const login: string | undefined = json.sender?.login?.toLowerCase(); if ( login &&