Skip to content

FEATURE: per-topic unsubscribe option in emails#9

Open
akshayutture-augment wants to merge 1 commit into
email-notifications-enhancementfrom
topic-email-management
Open

FEATURE: per-topic unsubscribe option in emails#9
akshayutture-augment wants to merge 1 commit into
email-notifications-enhancementfrom
topic-email-management

Conversation

@akshayutture-augment

@akshayutture-augment akshayutture-augment commented Nov 14, 2025

Copy link
Copy Markdown

Test 2


Replicated from ai-code-review-evaluation/discourse-cursor#2


Note

Adds a per-topic unsubscribe endpoint and UI, updates email templates/links to point to it, and wires supporting routes, model helper, and tests.

  • Email/Notifications:
    • Add per-topic unsubscribe link support; pass unsubscribe_url and render %{unsubscribe_link} in notification.html.erb and text bodies via MessageBuilder.
    • Set unsubscribe_url to post.topic.unsubscribe_url in UserNotifications#send_notification_email.
    • Include List-Unsubscribe header and keep respond instructions formatting.
    • Update specs to assert presence of unsubscribe_url handling.
  • Backend:
    • New TopicsController#unsubscribe action to downgrade TopicUser.notification_level (to regular or muted) and render topic view; allow non-XHR.
    • Add routes GET /t/:slug/:topic_id/unsubscribe and fallback GET /t/:topic_id/unsubscribe.
    • Add Topic#unsubscribe_url helper.
  • Frontend:
    • New route topicUnsubscribe, controller topic-unsubscribe.js.es6, view, and template templates/topic/unsubscribe.hbs with topic-notifications-button.
    • Load topic via PostStream.loadTopicView, hide notificationReasonText, and show footer.
    • Styles for .topic-unsubscribe .notification-options dropdown.
    • dropdown-button only renders title <h4> when title is present; other minor ES6/const cleanups.
  • i18n:
    • Add client keys under topic.unsubscribe.* and server unsubscribe_link text including per-topic link.

Written by Cursor Bugbot for commit 6669a2d. Configure here.

@akshayutture-augment

Copy link
Copy Markdown
Author

cursor review

tu.notification_level = TopicUser.notification_levels[:muted]
end

tu.save!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unsubscribe fails for missing topic user.

The unsubscribe method calls TopicUser.find_by which returns nil when no TopicUser record exists for the user-topic combination. The code then attempts to access tu.notification_level and call tu.save! without checking if tu is nil, causing a NoMethodError when users who haven't interacted with the topic try to unsubscribe.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants