improvement(emails): update unsub page, standardize unsub process#2881
Merged
waleedlatif1 merged 1 commit intostagingfrom Jan 19, 2026
Merged
improvement(emails): update unsub page, standardize unsub process#2881waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThis PR refactors the unsubscribe system to use a placeholder-based approach and updates the unsubscribe page UI for better consistency with the rest of the application. Key Changes:
Architecture improvements:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant EmailTemplate
participant Mailer
participant UnsubUtils
participant EmailClient
participant UnsubPage
participant API
participant DB
Note over EmailTemplate,Mailer: Email Sending Flow
EmailTemplate->>Mailer: sendEmail(options)
Mailer->>UnsubUtils: isUnsubscribed(email, type)
UnsubUtils->>DB: Check email preferences
DB-->>UnsubUtils: Return preferences
alt User has unsubscribed
UnsubUtils-->>Mailer: true
Mailer-->>EmailTemplate: Skip email
else User subscribed
UnsubUtils-->>Mailer: false
Mailer->>UnsubUtils: generateUnsubscribeToken(email, emailType)
UnsubUtils-->>Mailer: token
Mailer->>Mailer: Replace {{UNSUBSCRIBE_TOKEN}} and {{UNSUBSCRIBE_EMAIL}}
Mailer->>EmailClient: Send email with unsubscribe link
EmailClient-->>User: Email delivered
end
Note over User,DB: Unsubscribe Flow
User->>UnsubPage: Click unsubscribe link (email + token)
UnsubPage->>API: GET /api/users/me/settings/unsubscribe
API->>UnsubUtils: verifyUnsubscribeToken(email, token)
UnsubUtils-->>API: {valid: true, emailType}
API->>UnsubUtils: getEmailPreferences(email)
UnsubUtils->>DB: Query preferences
DB-->>UnsubUtils: Current preferences
UnsubUtils-->>API: Preferences
API-->>UnsubPage: {success, emailType, isTransactional, currentPreferences}
alt Transactional Email
UnsubPage->>User: Show cannot unsubscribe message
else Non-transactional Email
User->>UnsubPage: Select unsubscribe option
UnsubPage->>API: POST /api/users/me/settings/unsubscribe
API->>UnsubUtils: verifyUnsubscribeToken(email, token)
UnsubUtils-->>API: {valid: true}
API->>UnsubUtils: updateEmailPreferences(email, prefs)
UnsubUtils->>DB: Upsert settings with new preferences
DB-->>UnsubUtils: Success
UnsubUtils-->>API: true
API-->>UnsubPage: {success: true}
UnsubPage->>User: Show success message
end
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type of Change
Testing
N/A
Checklist