FEATURE: per-topic unsubscribe option in emails#9
Conversation
Codoki PR ReviewSummary: Add per-topic unsubscribe, ensure secure tokenization
Issues (Critical & High only)
Showing top 2 issues. Critical: 1, High: 1. See inline suggestions for more. Key Feedback (click to expand)
Confidence: 2/5 — Not ready to merge (1 critical · 1 high · status: Requires changes) Sequence DiagramsequenceDiagram
participant UserNotifications
participant Topic
participant EmailMessageBuilder
UserNotifications->>Topic: unsubscribe_url
Topic-->>UserNotifications: url + "/unsubscribe"
UserNotifications->>EmailMessageBuilder: build(body, add_unsubscribe_link, unsubscribe_url)
EmailMessageBuilder-->>UserNotifications: message with List-Unsubscribe header
React with 👍 or 👎 if you found this review useful. |
| if slugs_do_not_match || (!request.format.json? && params[:slug].blank?) | ||
| return redirect_to @topic_view.topic.unsubscribe_url, status: 301 | ||
| end | ||
|
|
There was a problem hiding this comment.
| ```suggestion | |
| tu = TopicUser.get(@topic_view.topic, current_user) | |
| current_level = tu ? tu.notification_level : TopicUser.notification_levels[:regular] | |
| desired_level = current_level > TopicUser.notification_levels[:regular] ? TopicUser.notification_levels[:regular] : TopicUser.notification_levels[:muted] | |
| TopicUser.change(current_user.id, params[:topic_id], notification_level: desired_level) |
|
|
||
| export default ObjectController.extend({ | ||
|
|
||
| stopNotificiationsText: function() { |
There was a problem hiding this comment.
💡 Low: Typo in property name ('Notificiations'). It works because the template uses the same name, but it invites future bugs and makes the code harder to read.
| stopNotificiationsText: function() { | |
| ```suggestion | |
| stopNotificationsText: function() { |
| url | ||
| end | ||
|
|
||
| def unsubscribe_url |
There was a problem hiding this comment.
🛑 Critical: Security: The per-topic unsubscribe URL currently contains no user-scoped, signed token, which allows unintended or unauthorized unsubscribes if the endpoint changes state on GET (e.g., by link scanners or third parties). Ensure the URL carries a cryptographically signed, user-specific token and that the server verifies it before changing notification state; alternatively, make GET show a confirmation page and require a tokenized POST to apply changes.
No description provided.