Skip to content

Conversation

@everettbu
Copy link
Contributor

@everettbu everettbu commented Jul 29, 2025

Test 2

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR implements a per-topic email unsubscribe feature that allows users to unsubscribe from notifications for specific topics rather than all email notifications. The implementation spans both frontend and backend components:

Backend Changes:

  • Adds a new unsubscribe action to TopicsController that toggles notification levels between regular and muted states
  • Introduces new routes /t/:slug/:topic_id/unsubscribe and /t/:topic_id/unsubscribe for handling unsubscribe requests
  • Extends the Topic model with an unsubscribe_url method that generates topic-specific unsubscribe URLs
  • Updates UserNotifications mailer to include the per-topic unsubscribe URL in email notifications
  • Modifies email templates to ensure unsubscribe links are consistently displayed

Frontend Changes:

  • Creates new Ember.js components including a route (topic-unsubscribe.js.es6), controller (topic-unsubscribe.js.es6), view, and template for the unsubscribe interface
  • Adds client-side routing support for the unsubscribe functionality
  • Implements defensive programming in the dropdown button component to handle optional titles
  • Updates CSS styles to support the new unsubscribe interface components

Localization and Configuration:

  • Adds new localization strings for both server and client-side unsubscribe messaging
  • Updates email notification templates to include per-topic unsubscribe options alongside existing preference links
  • Includes comprehensive test updates for the Email::MessageBuilder to handle the new unsubscribe URL parameter

The feature integrates seamlessly with Discourse's existing notification system while providing users more granular control over their email subscriptions. Users can now unsubscribe from individual topic notifications directly from email links without affecting their global notification preferences.

Confidence score: 2/5

  • This PR has significant implementation issues that make it unsafe to merge in its current state
  • Multiple critical bugs including typos, potential nil pointer exceptions, missing error handling, and deprecated API usage could cause immediate production failures
  • All files need attention, particularly the controllers, JavaScript components, templates, and CSS files which contain syntax errors and logic flaws

18 files reviewed, 4 comments

Edit Code Review Bot Settings | Greptile


export default ObjectController.extend({

stopNotificiationsText: function() {
Copy link

Choose a reason for hiding this comment

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

syntax: Typo: 'stopNotificiationsText' should be 'stopNotificationsText' (missing 'a' in 'Notifications')

Suggested change
stopNotificiationsText: function() {
stopNotificationsText: function() {

@@ -0,0 +1,8 @@
<div class="container">
<p>
{{{stopNotificiationsText}}}
Copy link

Choose a reason for hiding this comment

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

syntax: Typo in property name: 'stopNotificiationsText' should be 'stopNotificationsText' (missing 'n' in 'Notifications')

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

return redirect_to @topic_view.topic.unsubscribe_url, status: 301
end

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

Choose a reason for hiding this comment

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

logic: Potential nil pointer exception - if no TopicUser record exists, tu will be nil and calling methods on it will crash

Suggested change
tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id])
tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id])
return render json: {error: "Topic user not found"}, status: 404 unless tu

:change_post_owners,
:bookmark]
:bookmark,
:unsubscribe]
Copy link

Choose a reason for hiding this comment

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

logic: Authentication concern - email unsubscribe links typically work without login, but this requires authentication


<% context_posts.each do |p| %>
<%= render :partial => 'email/post', :locals => {:post => p} %>
<h4 class='.previous-discussion'><%= t "user_notifications.previous_discussion" %></h4>
Copy link

Choose a reason for hiding this comment

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

syntax: CSS selector syntax error: '.previous-discussion' should not have a leading dot in the class attribute

Suggested change
<h4 class='.previous-discussion'><%= t "user_notifications.previous_discussion" %></h4>
<h4 class='previous-discussion'><%= t "user_notifications.previous_discussion" %></h4>

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