github webhook: Always send messages for team edits.

If there are unsupported keys, we still log an error,
but we now also send a message to the stream.  (This
is a good tradeoff for the github webhook, since users
can just turn off notifications if they find it spammy.
Also, we intend to support "repository" soon.)

This is a bit of an experiment to see how this plays
in the field:

    * will customers notice the change?
    * will Sentry reports look any different?
This commit is contained in:
Steve Howell
2020-09-02 13:15:50 +00:00
committed by Tim Abbott
parent c6b9a23c17
commit 5bff66b450
2 changed files with 42 additions and 5 deletions

View File

@@ -424,7 +424,9 @@ A temporary team so that I can get some webhook fixtures!
for event in ignored_events:
self.verify_post_is_ignored(payload, event)
def test_team_edited_error_handling(self) -> None:
def test_team_edited_with_unsupported_keys(self) -> None:
self.subscribe(self.test_user, self.STREAM_NAME)
event = "team"
payload = dict(
action="edited",
@@ -440,13 +442,21 @@ A temporary team so that I can get some webhook fixtures!
log_mock = patch("zerver.decorator.webhook_unexpected_events_logger.exception")
with log_mock as m:
msg = self.client_post(
stream_message = self.send_webhook_payload(
self.test_user,
self.url,
payload,
HTTP_X_GITHUB_EVENT=event,
content_type="application/json",
)
self.assert_stream_message(
message=stream_message,
stream_name=self.STREAM_NAME,
topic_name="team My Team",
content="Team has changes to `bogus_key1/bogus_key2` data."
)
m.assert_called_once()
msg = m.call_args[0][0]
stack_info = m.call_args[1]["stack_info"]