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/github: Gate PR review comment edits on concise_edit_format.

Niloth P3b7893b0dada
diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py
index 7ece7830ab1..af1542f5bb0 100644
--- a/zerver/webhooks/github/tests.py
+++ b/zerver/webhooks/github/tests.py
@@ -473,6 +473,24 @@ class GitHubWebhookTest(WebhookTestCase):
expected_message = ":speech_balloon: baxterthehacker created [PR review comment on #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n``` quote\nMaybe you should use more emojji on this line.\n```"
self.check_webhook("pull_request_review_comment", expected_topic_name, expected_message)
+ def test_pull_request_review_comment_edited_msg(self) -> None:
+ payload = orjson.loads(self.get_body("pull_request_review_comment"))
+ payload["action"] = "edited"
+ payload["changes"] = {"body": {"from": "The comment, before being edited."}}
+ comment_link = "[PR review comment](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692)"
+ expected_messages = {
+ "true": f":speech_balloon: baxterthehacker edited {comment_link}.",
+ "false": f":speech_balloon: baxterthehacker edited {comment_link}:\n\n``` quote\nMaybe you should use more emojji on this line.\n```",
+ }
+ for concise_edit_format, expected_message in expected_messages.items():
+ self.url = self.build_webhook_url(concise_edit_format=concise_edit_format)
+ self.check_webhook(
+ "pull_request_review_comment",
+ TOPIC_PR,
+ expected_message,
+ custom_payload=payload,
+ )
+
def test_pull_request_locked(self) -> None:
expected_message = "tushar912 has locked [PR #1](https://github.com/tushar912/public-repo/pull/1) as off-topic and limited conversation to collaborators."
self.check_webhook("pull_request__locked", TOPIC_PR, expected_message)
diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py
index 13efbf0aa08..839bb8ba2b6 100644
--- a/zerver/webhooks/github/view.py
+++ b/zerver/webhooks/github/view.py
@@ -823,7 +823,7 @@ def get_pull_request_review_comment_body(helper: Helper) -> str:
include_title = helper.include_title
action = payload["action"].tame(check_string)
message = None
- if action == "created":
+ if action == "created" or (action == "edited" and not helper.concise_edit_format):
message = payload["comment"]["body"].tame(check_string)
title = "on #{} {}".format(