discourse/plugins/discourse-github/app/lib
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
..
commits_populator.rb
github_badges.rb
github_badges_repo_setting_validator.rb
github_linkback.rb FIX: Skip GitHub linkback when topic is already linked (#37633) 2026-02-09 14:31:27 +01:00
github_linkback_access_token_setting_validator.rb
github_permalinks.rb