0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/app
Jake Goldsborough edf30ae27e
FEATURE: badge notifications link to the post that earned them
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.
2026-05-27 09:04:38 -07:00
..
assets FEATURE: Sticky sort header for nested replies (#40307) 2026-05-27 10:39:23 -05:00
controllers DEV: Remove enable_simplified_category_creation old code (#40108) 2026-05-27 10:04:46 +10:00
helpers UX: Drop legacy mobile-mode site settings (#40226) 2026-05-26 09:23:13 +01:00
jobs FIX: Skip rejected reviewables in pending users reminder (#40304) 2026-05-27 16:37:52 +02:00
mailers DEV: Enable Style/RedundantParentheses rubocop rule (#40095) 2026-05-19 15:48:09 +02:00
models FIX: Approve users stuck with a non-pending ReviewableUser (#40303) 2026-05-27 16:38:01 +02:00
queries/reports FIX: Enforce can_see_ip checks across admin IP features (#40019) 2026-05-19 11:37:20 +08:00
serializers FEATURE: Sticky sort header for nested replies (#40307) 2026-05-27 10:39:23 -05:00
services FEATURE: badge notifications link to the post that earned them 2026-05-27 09:04:38 -07:00
views UX: Drop legacy mobile-mode site settings (#40226) 2026-05-26 09:23:13 +01:00