From e373df88e0d221907f69c1db22de69286aac4d7a Mon Sep 17 00:00:00 2001 From: PIG208 <359101898@qq.com> Date: Wed, 14 Jul 2021 00:37:49 +0800 Subject: [PATCH] webhooks: Make github webhook support event filtering system. --- zerver/webhooks/github/tests.py | 1 + zerver/webhooks/github/view.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py index 6b8af8a08f..69ecddb949 100644 --- a/zerver/webhooks/github/tests.py +++ b/zerver/webhooks/github/tests.py @@ -18,6 +18,7 @@ class GitHubWebhookTest(WebhookTestCase): STREAM_NAME = "github" URL_TEMPLATE = "/api/v1/external/github?stream={stream}&api_key={api_key}" WEBHOOK_DIR_NAME = "github" + VIEW_FUNCTION_NAME = "api_github_webhook" def test_ping_event(self) -> None: expected_message = "GitHub webhook has been successfully configured by TomaszKolek." diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py index 62235f15ef..74a8963d1a 100644 --- a/zerver/webhooks/github/view.py +++ b/zerver/webhooks/github/view.py @@ -672,8 +672,10 @@ IGNORED_TEAM_ACTIONS = [ "removed_from_repository", ] +ALL_EVENT_TYPES = list(EVENT_FUNCTION_MAPPER.keys()) -@webhook_view("GitHub", notify_bot_owner_on_invalid_json=True) + +@webhook_view("GitHub", notify_bot_owner_on_invalid_json=True, all_event_types=ALL_EVENT_TYPES) @has_request_variables def api_github_webhook( request: HttpRequest, @@ -709,7 +711,7 @@ def api_github_webhook( ) body = body_function(helper) - check_send_webhook_message(request, user_profile, subject, body) + check_send_webhook_message(request, user_profile, subject, body, event) return json_success()