Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • add one-click unsubscribe

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 19, 2025 3:24am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 19, 2025

Greptile Summary

This PR adds RFC 8058 compliant one-click unsubscribe support for marketing emails. The changes enable email clients to display a native "Unsubscribe" button by adding proper List-Unsubscribe and List-Unsubscribe-Post headers.

  • API Endpoint: Modified POST handler to detect application/x-www-form-urlencoded content type and parse email/token from URL query parameters (as required by RFC 8058 for one-click unsubscribe)
  • Mailer Refactoring: Extracted unsubscribe header generation into reusable addUnsubscribeData helper function
  • Batch Email Support: Added unsubscribe checking and List-Unsubscribe headers to sendBatchWithResend function, which previously lacked this functionality
  • Comment Cleanup: Removed unnecessary inline comments from multiple files

Confidence Score: 5/5

  • This PR is safe to merge - it correctly implements RFC 8058 one-click unsubscribe with proper token validation and no security regressions.
  • The implementation follows RFC 8058 correctly by parsing email/token from URL params for form-encoded requests. The refactoring is clean and adds missing unsubscribe support to batch emails. Existing tests pass and the token verification ensures security.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/api/users/me/settings/unsubscribe/route.ts Added one-click unsubscribe support per RFC 8058 - POST endpoint now handles both JSON body and form-urlencoded requests with email/token from URL params. Implementation correctly follows RFC 8058 spec.
apps/sim/app/unsubscribe/unsubscribe.tsx Comment removals only - no functional changes to the unsubscribe UI component.
apps/sim/lib/messaging/email/mailer.ts Refactored unsubscribe header generation into addUnsubscribeData helper. Added unsubscribe checking and List-Unsubscribe headers to batch email sending in sendBatchWithResend.

Sequence Diagram

sequenceDiagram
    participant EC as Email Client
    participant API as Unsubscribe API
    participant DB as Database
    
    Note over EC,DB: One-Click Unsubscribe Flow (RFC 8058)
    
    EC->>API: POST /unsubscribe (form-urlencoded)<br/>with email and token in URL
    API->>API: Detect form-urlencoded content type
    API->>API: Parse email and token from URL params
    API->>API: Verify unsubscribe token
    API->>DB: Update email preferences
    DB-->>API: Success
    API-->>EC: 200 OK

    Note over EC,DB: Traditional Unsubscribe Flow
    
    EC->>API: POST /unsubscribe (JSON body)
    API->>API: Parse JSON body with email, token, type
    API->>API: Verify unsubscribe token
    API->>DB: Update email preferences
    DB-->>API: Success
    API-->>EC: 200 OK with message
Loading

Copy link
Contributor

@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.

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1 waleedlatif1 merged commit 24356d9 into staging Dec 19, 2025
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/unsub branch December 19, 2025 05:16
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