8000 fix: Unsubscribe link for collection subscriptions by tommoor · Pull Request #8734 · outline/outline · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: Unsubscribe link for collection subscriptions #8734

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

Merged
merged 5 commits into from
Mar 22, 2025

Conversation

tommoor
Copy link
Member
@tommoor tommoor commented Mar 21, 2025

Hopefully all the existing tests make this easier to review – TLDR: We include a link to unsubscribe in document notification emails, when #8392 was added this wasn't updated to account for collection subscriptions.

@tommoor tommoor requested a review from Copilot March 21, 2025 03:24
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the unsubscribe link for collection subscriptions by adding the missing subscriptionId functionality to notifications and related endpoints. Key changes include:

  • Adding a migration to add the subscriptionId column to notifications.
  • Updating the notification recipient helper functions and tests to handle a Recipient type that includes an optional subscription.
  • Propagating subscriptionId to the unsubscribe URL, email templates, and various notification tasks.

Reviewed Changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
server/migrations/20250321021710-add-subscription-to-notifications.js Migration to add subscriptionId column
server/models/helpers/NotificationHelper.ts Updated recipient types and mapping logic for notifications
server/routes/api/subscriptions/subscriptions.ts Adjusted unsubscribe handling to include subscriptionId
server/models/Notification.ts Added subscription association and foreign key
server/models/Subscription.ts Added isCollectionSubscription getter
server/routes/api/subscriptions/schema.ts Added optional subscriptionId to schema
app/hooks/useQueryNotices.ts Added handling for the UnsubscribeCollection notice
server/emails/templates/DocumentPublishedOrUpdatedEmail.tsx Passed subscriptionId to the unsubscribe URL
shared/types.ts Added UnsubscribeCollection enum
server/queues/processors/EmailsProcessor.ts Included subscriptionId in notification payload
server/models/helpers/SubscriptionHelper.ts Updated unsubscribeUrl and unsubscribeToken to include subscriptionId
server/models/helpers/NotificationHelper.test.ts Updated tests to check for recipient.user.id and subscription linkage
server/queues/tasks/* Updated notification tasks to propagate subscriptionId to notifications
Files not reviewed (1)
  • shared/i18n/locales/en_US/translation.json: Language not supported

@tommoor tommoor requested a review from hmacr March 21, 2025 03:39
@tommoor tommoor changed the title fix: Unsubscribe link for collection subscriptions doesn't work fix: Unsubscribe link for collection subscriptions Mar 21, 2025
@hmacr
Copy link
Collaborator
hmacr commented Mar 21, 2025

oof terrible miss! thanks for fixing it 🙏 will test now.

@hmacr
Copy link
Collaborator
hmacr commented Mar 21, 2025

Passing subscriptionId could inadvertently unsubscribe from a different collection (collectionA) when a document is moved to another collection (collectionB) before the user clicks (could be after X days) on unsubscribe link. However, the end state feels correct as the user originally was subscribed to collectionA which allowed the email notif and they intend to unsubscribe from it.

Should be fine right? 🤔

@tommoor
Copy link
Member Author
tommoor commented Mar 21, 2025

I believe the intent is OK, should be very rare. Interesting though

@tommoor
Copy link
Member Author
tommoor commented Mar 21, 2025

Alternatively I could grab the collectionId from the subscription and use that in the unsubscribe url. The majority of changes here remain the same – honestly not sure which I prefer

@hmacr
Copy link
Collaborator
hmacr commented Mar 21, 2025

collectionId from the subscription and use that in the unsubscribe url

I think you meant using the latest collectionId in the deletion handler 🤔

honestly not sure which I prefer

Same, this edge-case must be veryyy rare - think we can leave it as-is? Just wanted to bring it up to cover the bases.

@tommoor
Copy link
Member Author
tommoor commented Mar 21, 2025

I think you meant using the latest collectionId in the deletion handler 🤔

well to fix the issue you raised it would need to be passed into the email -> unsubscribe url -> deletion handler yep

Copy link
Collaborator
@hmacr hmacr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great!

@tommoor tommoor force-pushed the tom/unsubscribe-collection-subscriptions branch from 8ae178f to d85f445 Compare March 21, 2025 23:12
@tommoor tommoor merged commit a48f6c7 into main Mar 22, 2025
12 checks passed
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
0