Skip to content

FEATURE: per-topic unsubscribe option in emails#2

Open
everettbu wants to merge 1 commit into
email-notifications-enhancement-copilotfrom
topic-email-management-copilot
Open

FEATURE: per-topic unsubscribe option in emails#2
everettbu wants to merge 1 commit into
email-notifications-enhancement-copilotfrom
topic-email-management-copilot

Conversation

@everettbu

Copy link
Copy Markdown

Test 2

Copilot AI review requested due to automatic review settings July 26, 2025 19:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a per-topic unsubscribe feature that allows users to unsubscribe from notifications for specific topics directly from email notifications, rather than needing to visit their general preferences page.

Key Changes:

  • Added topic-specific unsubscribe URLs to email notifications
  • Created new controller action and routes for topic unsubscribe functionality
  • Added frontend interface for managing topic notification preferences

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/email/message_builder.rb Adds support for topic-specific unsubscribe URLs in email templates
app/mailers/user_notifications.rb Passes topic unsubscribe URL to email builder
config/routes.rb Adds new routes for topic unsubscribe functionality
app/controllers/topics_controller.rb Implements unsubscribe action to modify notification levels
app/models/topic.rb Adds method to generate topic unsubscribe URLs
config/locales/server.en.yml Updates email unsubscribe text to include topic-specific option
config/locales/client.en.yml Adds localization strings for unsubscribe interface
Frontend files Implements JavaScript routes, controllers, and templates for unsubscribe UI
Test files Updates tests to include new unsubscribe URL parameter

end

tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id])

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

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

The code doesn't handle the case where TopicUser record doesn't exist. If find_by returns nil, the subsequent lines will raise a NoMethodError when trying to access tu.notification_level.

Suggested change
raise Discourse::NotFound unless tu

Copilot uses AI. Check for mistakes.
return I18n.t("topic.unsubscribe.stop_notifications", { title: this.get("model.fancyTitle") });
}.property("model.fancyTitle"),

})

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

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

There's a typo in the function name stopNotificiationsText - it should be stopNotificationsText (missing 'a' in 'notifications').

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,8 @@
<div class="container">
<p>
{{{stopNotificiationsText}}}

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

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

There's a typo in the property name stopNotificiationsText - it should be stopNotificationsText (missing 'a' in 'notifications'). This should match the corrected property name in the controller.

Suggested change
{{{stopNotificiationsText}}}
{{{stopNotificationsText}}}

Copilot uses AI. Check for mistakes.
end

def unsubscribe
@topic_view = TopicView.new(params[:topic_id], current_user)

Copilot AI Jul 26, 2025

Copy link

Choose a reason for hiding this comment

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

The unsubscribe action doesn't authenticate the user. Since it's accessing current_user, there should be authentication requirements to ensure only logged-in users can access this functionality.

Copilot uses AI. Check for mistakes.
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has been open for 60 days with no activity. To keep it open, remove the stale tag, push code, or add a comment. Otherwise, it will be closed in 14 days.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants