mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-07 17:36:22 +08:00
The GitHub linkback feature posts comments on PRs/issues/commits when they are mentioned in Discourse posts. However, it never checked whether the GitHub PR/issue/commit already contained a link back to the same Discourse topic (in its description or existing comments). This led to redundant linkback comments when a PR already referenced the topic. Before posting a linkback comment, we now fetch the PR/issue body and existing comments (or commit comments) from the GitHub API and check whether any of them already contain a URL pointing to the same Discourse topic. URL matching uses Discourse.route_for — the same mechanism used by the oneboxer, search, and TopicLink — to reliably recognize all topic URL formats (/t/slug/id, /t/id, /t/id/post_number, etc.). On any GitHub API error, the check fails open (still posts the linkback) to preserve the pre-existing behavior — and because if the GET fails, the subsequent POST will likely fail too. |
||
|---|---|---|
| .. | ||
| controllers/discourse_github | ||
| jobs | ||
| lib | ||
| models | ||