-
Notifications
You must be signed in to change notification settings - Fork 0
FEATURE: per-topic unsubscribe option in emails #9
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: email-notifications-enhancement
Are you sure you want to change the base?
FEATURE: per-topic unsubscribe option in emails #9
Conversation
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.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 1/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Email
participant Browser
participant TopicsController
participant TopicUser
participant TopicView
participant MessageBus
User->>Email: Receives notification email
Email->>Email: Contains unsubscribe_url link
User->>Browser: Clicks unsubscribe link
Browser->>TopicsController: GET /t/:slug/:id/unsubscribe
TopicsController->>TopicsController: ensure_logged_in filter
TopicsController->>TopicView: Create TopicView
TopicView-->>TopicsController: Return topic data
TopicsController->>TopicUser: find_by(user_id, topic_id)
TopicUser-->>TopicsController: Return TopicUser (or nil)
TopicsController->>TopicUser: Update notification_level
TopicUser->>TopicUser: save!
TopicUser->>MessageBus: Publish notification_level_change
TopicsController->>Browser: Render topic show page
Browser-->>User: Display unsubscribe confirmation
|
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, 2 comments
| tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id]) | ||
|
|
||
| if tu.notification_level > TopicUser.notification_levels[:regular] | ||
| tu.notification_level = TopicUser.notification_levels[:regular] | ||
| else | ||
| tu.notification_level = TopicUser.notification_levels[:muted] | ||
| end | ||
|
|
||
| tu.save! |
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 returns nil if no TopicUser record exists, causing NoMethodError on line 107
| tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id]) | |
| if tu.notification_level > TopicUser.notification_levels[:regular] | |
| tu.notification_level = TopicUser.notification_levels[:regular] | |
| else | |
| tu.notification_level = TopicUser.notification_levels[:muted] | |
| end | |
| tu.save! | |
| tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id]) | |
| if tu | |
| if tu.notification_level > TopicUser.notification_levels[:regular] | |
| tu.notification_level = TopicUser.notification_levels[:regular] | |
| else | |
| tu.notification_level = TopicUser.notification_levels[:muted] | |
| end | |
| tu.save! | |
| else | |
| TopicUser.create!( | |
| user_id: current_user.id, | |
| topic_id: params[:topic_id], | |
| notification_level: TopicUser.notification_levels[:muted] | |
| ) | |
| end |
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/controllers/topics_controller.rb
Line: 105:113
Comment:
**logic:** `find_by` returns `nil` if no `TopicUser` record exists, causing `NoMethodError` on line 107
```suggestion
tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id])
if tu
if tu.notification_level > TopicUser.notification_levels[:regular]
tu.notification_level = TopicUser.notification_levels[:regular]
else
tu.notification_level = TopicUser.notification_levels[:muted]
end
tu.save!
else
TopicUser.create!(
user_id: current_user.id,
topic_id: params[:topic_id],
notification_level: TopicUser.notification_levels[:muted]
)
end
```
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: typo in function name: 'Notificiations' should be 'Notifications'
| 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:** typo in function name: 'Notificiations' should be 'Notifications'
```suggestion
stopNotificationsText: function() {
```
How can I resolve this? If you propose a fix, please make it concise.
Test 2
Replicated from ai-code-review-evaluation/discourse-greptile#2