mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
webhooks/github: Include full repository name in notification messages.
This changes the notification messages for events that currently just include the string `"the repository"` to also include the full (`org/repo`) name of the affected repository. Messages for the following events are changed: - `public` - `star` - `watch` - `repository` - `team_add` Background: we're using the GitHub integration for org-wide notifications for the [Bytecode Alliance Zulip](bytecodealliance.zulipchat.com/), and having all messages just say "the repository" isn't ideal. Even now one can hover over the link to see the repo's url, but it'd be much nicer if the message just contained the full name. I also changed the message for `star` to include a link to the repository, same as the `watch` notification.
This commit is contained in:
committed by
Tim Abbott
parent
b456094823
commit
6d6d43188d
@@ -207,8 +207,9 @@ def get_push_commits_body(payload: Dict[str, Any]) -> str:
|
||||
)
|
||||
|
||||
def get_public_body(payload: Dict[str, Any]) -> str:
|
||||
return "{} made [the repository]({}) public.".format(
|
||||
return "{} made the repository [{}]({}) public.".format(
|
||||
get_sender_name(payload),
|
||||
get_repository_full_name(payload),
|
||||
payload['repository']['html_url'],
|
||||
)
|
||||
|
||||
@@ -224,20 +225,23 @@ def get_wiki_pages_body(payload: Dict[str, Any]) -> str:
|
||||
return f"{get_sender_name(payload)}:\n{wiki_info.rstrip()}"
|
||||
|
||||
def get_watch_body(payload: Dict[str, Any]) -> str:
|
||||
return "{} starred [the repository]({}).".format(
|
||||
return "{} starred the repository [{}]({}).".format(
|
||||
get_sender_name(payload),
|
||||
get_repository_full_name(payload),
|
||||
payload['repository']['html_url'],
|
||||
)
|
||||
|
||||
def get_repository_body(payload: Dict[str, Any]) -> str:
|
||||
return "{} {} [the repository]({}).".format(
|
||||
return "{} {} the repository [{}]({}).".format(
|
||||
get_sender_name(payload),
|
||||
payload.get('action'),
|
||||
get_repository_full_name(payload),
|
||||
payload['repository']['html_url'],
|
||||
)
|
||||
|
||||
def get_add_team_body(payload: Dict[str, Any]) -> str:
|
||||
return "[The repository]({}) was added to team {}.".format(
|
||||
return "The repository [{}]({}) was added to team {}.".format(
|
||||
get_repository_full_name(payload),
|
||||
payload['repository']['html_url'],
|
||||
payload['team']['name'],
|
||||
)
|
||||
@@ -407,10 +411,12 @@ Check [{name}]({html_url}) {status} ({conclusion}). ([{short_hash}]({commit_url}
|
||||
return template.format(**kwargs)
|
||||
|
||||
def get_star_body(payload: Dict[str, Any]) -> str:
|
||||
template = "{user} {action} the repository."
|
||||
template = "{user} {action} the repository [{repo}]({url})."
|
||||
return template.format(
|
||||
user=payload['sender']['login'],
|
||||
action='starred' if payload['action'] == 'created' else 'unstarred',
|
||||
repo=get_repository_full_name(payload),
|
||||
url=payload['repository']['html_url'],
|
||||
)
|
||||
|
||||
def get_ping_body(payload: Dict[str, Any]) -> str:
|
||||
@@ -419,6 +425,9 @@ def get_ping_body(payload: Dict[str, Any]) -> str:
|
||||
def get_repository_name(payload: Dict[str, Any]) -> str:
|
||||
return payload['repository']['name']
|
||||
|
||||
def get_repository_full_name(payload: Dict[str, Any]) -> str:
|
||||
return payload['repository']['full_name']
|
||||
|
||||
def get_organization_name(payload: Dict[str, Any]) -> str:
|
||||
return payload['organization']['login']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user