-
Notifications
You must be signed in to change notification settings - Fork 0
FEATURE: per-topic unsubscribe option in emails #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: greptile_competitor_benchmark_full_2_base_feature_per-topic_unsubscribe_option_in_emails
Are you sure you want to change the base?
Conversation
Greptile SummaryThis PR adds per-topic unsubscribe functionality allowing users to unsubscribe from individual topics via email links. Users receive topic-specific unsubscribe links in notification emails that toggle their notification level between regular and muted. Major changes:
Critical issues found:
Confidence Score: 1/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Email
participant Browser
participant TopicsController
participant TopicUser
participant TopicView
User->>Email: Receives notification email
Email->>User: Shows unsubscribe link
User->>Browser: Clicks topic unsubscribe link
Browser->>TopicsController: GET /t/:slug/:id/unsubscribe
TopicsController->>TopicView: Create TopicView
TopicView-->>TopicsController: Topic data
TopicsController->>TopicUser: find_by(user_id, topic_id)
TopicUser-->>TopicsController: TopicUser record (or nil)
alt TopicUser exists
TopicsController->>TopicUser: Update notification_level
TopicUser-->>TopicsController: Saved
TopicsController->>Browser: Render topic with notification controls
else TopicUser is nil
TopicsController->>Browser: Error (NoMethodError)
end
Browser->>User: Shows unsubscribe page
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
18 files reviewed, 4 comments
| 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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: find_by can return nil if no TopicUser record exists for this user and topic. The subsequent lines will raise NoMethodError when trying to call methods on nil.
| 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]) || TopicUser.create(user_id: current_user.id, topic_id: params[:topic_id]) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/controllers/topics_controller.rb
Line: 105:105
Comment:
**logic:** `find_by` can return `nil` if no `TopicUser` record exists for this user and topic. The subsequent lines will raise `NoMethodError` when trying to call methods on `nil`.
```suggestion
tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id]) || TopicUser.create(user_id: current_user.id, topic_id: params[:topic_id])
```
How can I resolve this? If you propose a fix, please make it concise.| @@ -0,0 +1,8 @@ | |||
| <div class="container"> | |||
| <p> | |||
| {{{stopNotificiationsText}}} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Using triple-brace {{{ allows unescaped HTML which creates XSS vulnerability. The fancyTitle could contain malicious HTML/JavaScript.
| {{{stopNotificiationsText}}} | |
| {{stopNotificiationsText}} |
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/assets/javascripts/discourse/templates/topic/unsubscribe.hbs
Line: 3:3
Comment:
**logic:** Using triple-brace `{{{` allows unescaped HTML which creates XSS vulnerability. The `fancyTitle` could contain malicious HTML/JavaScript.
```suggestion
{{stopNotificiationsText}}
```
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| export default ObjectController.extend({ | ||
|
|
||
| stopNotificiationsText: function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: stopNotificiationsText is misspelled (should be stopNotificationsText with 'a'). This typo is referenced in the template.
| stopNotificiationsText: function() { | |
| stopNotificationsText: function() { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/assets/javascripts/discourse/controllers/topic-unsubscribe.js.es6
Line: 5:5
Comment:
**syntax:** `stopNotificiationsText` is misspelled (should be `stopNotificationsText` with 'a'). This typo is referenced in the template.
```suggestion
stopNotificationsText: function() {
```
How can I resolve this? If you propose a fix, please make it concise.| @@ -0,0 +1,8 @@ | |||
| <div class="container"> | |||
| <p> | |||
| {{{stopNotificiationsText}}} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: stopNotificiationsText is misspelled (should be stopNotificationsText with 'a').
| {{{stopNotificiationsText}}} | |
| {{stopNotificationsText}} |
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/assets/javascripts/discourse/templates/topic/unsubscribe.hbs
Line: 3:3
Comment:
**syntax:** `stopNotificiationsText` is misspelled (should be `stopNotificationsText` with 'a').
```suggestion
{{stopNotificationsText}}
```
How can I resolve this? If you propose a fix, please make it concise.
Benchmark PR from qodo-benchmark/discourse-qodo#2