Repository: zulip/zulip

Issue:
GitHub integration: How about linking sender?
GitHub integration includes a sender to message content. For example, `XXX starred the repository [zulip/zulip](https://github.com/zulip/zulip]` is a message content of a star event.

How about making the sender part clickable like repository name?
For example, `[XXX](https://github.com/XXX) starred the repository [zulip/zulip](https://github.com/zulip/zulip]` for a star event.

We can do this only for a star event by the following change:

```diff
diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py
index db74604bbc..a425f78bb6 100644
--- a/zerver/webhooks/github/view.py
+++ b/zerver/webhooks/github/view.py
@@ -597,9 +597,10 @@ Check [{name}]({html_url}) {status} ({conclusion}). ([{short_hash}]({commit_url}
 
 def get_star_body(helper: Helper) -> str:
     payload = helper.payload
-    template = "{user} {action} the repository [{repo}]({url})."
+    template = "[{user}]({user_url}) {action} the repository [{repo}]({url})."
     return template.format(
-        user=payload["sender"]["login"].tame(check_string),
+        user=get_sender_name(payload),
+        user_url=get_sender_url(payload),
         action="starred" if payload["action"].tame(check_string) == "created" else "unstarred",
         repo=get_repository_full_name(payload),
         url=payload["repository"]["html_url"].tame(check_string),
@@ -627,6 +628,10 @@ def get_sender_name(payload: WildValue) -> str:
     return payload["sender"]["login"].tame(check_string)
 
 
+def get_sender_url(payload: WildValue) -> str:
+    return payload["sender"]["html_url"].tame(check_string)
+
+
 def get_branch_name_from_ref(ref_string: str) -> str:
     return re.sub(r"^refs/heads/", "", ref_string)
 
```

I think that other events can be done with similar changes.

What do you think about this proposal? (If this proposal is acceptable, I think that we can mark this as "good-first-issue".)


Discussion:
@zulipbot add "help wanted" "area: integrations"
Hello @zulip/server-integrations members, this issue was labeled with the "area: integrations" label, so you may want to check it out!

<!-- areaLabelAddition -->

@zulipbot claim
Welcome to Zulip, @dhruv302003! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!

Here's some tips to get you off to a good start:

- Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.
- [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.

As you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.

See you on the other side (that is, the pull request side)!

@dhruv302003 We noticed that you have not made any updates to this issue or linked PRs for 10 days. Please comment here if you are still actively working on it. Otherwise, we'd appreciate a quick `@zulipbot abandon` comment so that someone else can claim this issue and continue from where you left off.

If we don't hear back, you will be automatically unassigned in 4 days. Thanks!

<!-- inactiveWarning -->

@zulipbot I am still working on it

Resolving patch:
diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py
--- a/zerver/webhooks/github/view.py
+++ b/zerver/webhooks/github/view.py
@@ -364,7 +364,7 @@ def get_team_body(helper: Helper) -> str:
     payload = helper.payload
     changes = payload["changes"]
     if "description" in changes:
-        actor = payload["sender"]["login"].tame(check_string)
+        actor = get_sender_name(payload)
         new_description = payload["team"]["description"].tame(check_string)
         return f"**{actor}** changed the team description to:\n```quote\n{new_description}\n```"
     if "name" in changes:
@@ -597,9 +597,10 @@ def get_check_run_body(helper: Helper) -> str:
 
 def get_star_body(helper: Helper) -> str:
     payload = helper.payload
-    template = "{user} {action} the repository [{repo}]({url})."
+    template = "[{user}]({user_url}) {action} the repository [{repo}]({url})."
     return template.format(
-        user=payload["sender"]["login"].tame(check_string),
+        user=get_sender_name(payload),
+        user_url=get_sender_url(payload),
         action="starred" if payload["action"].tame(check_string) == "created" else "unstarred",
         repo=get_repository_full_name(payload),
         url=payload["repository"]["html_url"].tame(check_string),
@@ -627,6 +628,10 @@ def get_sender_name(payload: WildValue) -> str:
     return payload["sender"]["login"].tame(check_string)
 
 
+def get_sender_url(payload: WildValue) -> str:
+    return payload["sender"]["html_url"].tame(check_string)
+
+
 def get_branch_name_from_ref(ref_string: str) -> str:
     return re.sub(r"^refs/heads/", "", ref_string)
 


Test patch:
diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py
--- a/zerver/webhooks/github/tests.py
+++ b/zerver/webhooks/github/tests.py
@@ -25,7 +25,7 @@ def test_ping_event(self) -> None:
         self.check_webhook("ping", TOPIC_REPO, expected_message)
 
     def test_star_event(self) -> None:
-        expected_message = "Codertocat starred the repository [Codertocat/Hello-World](https://github.com/Codertocat/Hello-World)."
+        expected_message = "[Codertocat](https://github.com/Codertocat) starred the repository [Codertocat/Hello-World](https://github.com/Codertocat/Hello-World)."
         expected_topic = "Hello-World"
         self.check_webhook("star", expected_topic, expected_message)