mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 02:59:07 +08:00
Per-post badges (Thank You, Nice Reply, etc.) record the triggering post in user_badges.post_id, but the granted-badge notification never carried it, so the notification only linked to the generic badge page. Now when a badge was granted for a specific post, the notification includes post_id / post_number / topic_id / topic_title in its data, links straight to that post, and reads "Earned 'X' for your post in <topic>". Non-post badges are unchanged (still link to the badge page, same description). - BadgeGranter.send_notification takes an optional post_id: and, when present and the post is visible to the recipient (Post.find_by skips trashed; a guardian check drops hidden-category posts), denormalizes the post/topic refs into the notification data. - Single-grant path passes user_badge.post_id. - Backfill path: the insert already wrote post_id; added it to the CTE RETURNING + outer SELECT so the per-row send_notification can pass row.post_id. - granted-badge notification type: linkHref goes to the post when topic_id + post_number are present, else the badge page; description uses the new granted_badge_for_post string when a topic_title is present. Specs: BadgeGranter includes post context on a post-grant, omits it for non-post badges, and omits it when the post isn't visible. JS: linkHref and description for the with-post case. Note: the backfill path now does a Post + User lookup per granted post-badge for the guardian check. Acceptable for correctness; can be batched later if backfill volume makes it a concern. |
||
|---|---|---|
| .. | ||
| assets | ||
| controllers | ||
| helpers | ||
| jobs | ||
| mailers | ||
| models | ||
| queries/reports | ||
| serializers | ||
| services | ||
| views | ||