mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
integrations: Improve GitHub issue labeled and unlabeled notifications.
Earlier, the notifications had no information about the labels being added or removed.
This commit is contained in:
committed by
Tim Abbott
parent
8fc28be8ca
commit
842e9d1aca
@@ -28,6 +28,7 @@ from zerver.lib.webhooks.git import (
|
||||
TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE,
|
||||
get_commits_comment_action_message,
|
||||
get_issue_event_message,
|
||||
get_issue_labeled_or_unlabeled_event_message,
|
||||
get_pull_request_event_message,
|
||||
get_push_commits_event_message,
|
||||
get_push_tag_event_message,
|
||||
@@ -160,6 +161,10 @@ def get_issue_body(helper: Helper) -> str:
|
||||
action = payload["action"].tame(check_string)
|
||||
issue = payload["issue"]
|
||||
has_assignee = "assignee" in payload
|
||||
|
||||
if action in ("labeled", "unlabeled"):
|
||||
return get_issue_labeled_or_unlabeled_body(helper)
|
||||
|
||||
base_message = get_issue_event_message(
|
||||
user_name=get_sender_name(payload),
|
||||
action=action,
|
||||
@@ -204,6 +209,23 @@ def get_issue_comment_body(helper: Helper) -> str:
|
||||
)
|
||||
|
||||
|
||||
def get_issue_labeled_or_unlabeled_body(helper: Helper) -> str:
|
||||
payload = helper.payload
|
||||
include_title = helper.include_title
|
||||
issue = payload["issue"]
|
||||
|
||||
return get_issue_labeled_or_unlabeled_event_message(
|
||||
user_name=get_sender_name(payload),
|
||||
action="added" if payload["action"].tame(check_string) == "labeled" else "removed",
|
||||
url=issue["html_url"].tame(check_string),
|
||||
number=issue["number"].tame(check_int),
|
||||
label_name=payload["label"]["name"].tame(check_string),
|
||||
label_url=payload["label"]["url"].tame(check_string),
|
||||
user_url=get_sender_url(payload),
|
||||
title=issue["title"].tame(check_string) if include_title else None,
|
||||
)
|
||||
|
||||
|
||||
def get_fork_body(helper: Helper) -> str:
|
||||
payload = helper.payload
|
||||
forkee = payload["forkee"]
|
||||
|
||||
Reference in New Issue
Block a user