Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

webhooks: Make github webhook support event filtering system.

PIG208e373df88e0d2
diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py
index 6b8af8a08f5..69ecddb9499 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 62235f15ef4..74a8963d1ad 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()