discourse/plugins/discourse-github/app
Régis Hanol 318eb49a30
FIX: Skip GitHub linkback when topic is already linked (#37633)
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.
2026-02-09 14:31:27 +01:00
..
controllers/discourse_github FEATURE: GitHub PR live status icon (#36313) 2025-12-04 21:42:44 +01:00
jobs PERF: optimize GitHub PR onebox rebaking (#36739) 2025-12-17 12:06:16 +01:00
lib FIX: Skip GitHub linkback when topic is already linked (#37633) 2026-02-09 14:31:27 +01:00
models