Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

feat: unsubscribe link - #1004

Merged
ojeytonwilliams merged 34 commits into
freeCodeCamp:mainfrom
gikf:feat/unsubscribe-link
Jul 18, 2022
Merged

ojeytonwilliams merged 34 commits into
freeCodeCamp:mainfrom
gikf:feat/unsubscribe-link

Conversation

@gikf

@gikf gikf commented Apr 13, 2022 •

Copy link
Copy Markdown
Member
  • I have read Chapter's contributing guidelines.
  • My pull request has a descriptive title (not a vague title like Update README.md).
  • My pull request targets the main branch of Chapter.

To do

  • Tune wording, and unify generating unsubscribe links.
  • Figure out sending batch emails with unsubscribe links included.
  • Be more explicit about what is being unsubscribed?
  • Tests.
  • More tests?
  • Clean up.

  • Related to As a user, I can unsubscribe from a specific chapters emails. #274
  • Sets pieces for implementing unsubscribing via link, sent in email.
  • Very drafty, some parts are just put in the appropriate places, some are waiting for new roles (actual mutation).
  • Still messy, but basic functionality is in.
  • Uses general /unsubscribe?token=${token} route. With signed token including user id, whether it's chapter or event subscription and id of the element. As that information is in token, I'm not sure if it's worth to use more detailed links.
  • Unsubscribing doesn't require being logged in. That means anybody with link can unsubscribe the owner of link. Without explicitly forcing user to log in, some more secure option could be, when visiting link with token, sending them another email, as a two-step process.
  • Adds batchSender allowing sending multiple emails, with changed subject/text per recipient, it expects generator function yielding at least email address, subject and text.
  • As long as token is valid, unsubscribing is idempotent.

@gitpod-io

gitpod-io Bot commented Apr 13, 2022

Copy link
Copy Markdown

@ghost

ghost commented Apr 13, 2022 •

Copy link
Copy Markdown
👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@allella

allella commented Apr 13, 2022 •

Copy link
Copy Markdown
Contributor

@gikf I wanted to be sure you've seen the earlier conversations about unsubscribe links and the chat about the difference between unfollowing / unsubscribing from a Chapter vs an event.

Also, there was some discussion on using unsigned JWOT tokens. I think @ojeytonwilliams made that suggestion.

#276 (comment)
#275 (comment)

@allella

allella commented Apr 13, 2022

Copy link
Copy Markdown
Contributor

There are also some draft examples of how the unsubscribe / unfollow link might appear in the email body or footer.
#276 (comment)

@gikf

gikf commented Apr 14, 2022

Copy link
Copy Markdown
Member Author

@allella thanks for these. I haven't got yet in mind specifics what means unsubscribing from chapter, this will surely help with that.

@gikf

gikf commented Jun 27, 2022

Copy link
Copy Markdown
Member Author

This is still messy and bit raw, but things are working. Some more general comments would be appreciated. The easiest way to get links is rsvping to the event and checking email with confirmation.

@allella

allella commented Jun 28, 2022

Copy link
Copy Markdown
Contributor

@gikf it seems this is code, but let me know if there's any less technical questions where I can help.

Thanks

@gikf

gikf commented Jun 28, 2022

Copy link
Copy Markdown
Member Author

@allella Does trying out functionality matches that? 🙂 Some insights on how currently the whole process works also would be useful.

@gikf
gikf marked this pull request as ready for review July 11, 2022 18:56
@gikf
gikf requested a review from a team July 11, 2022 18:56
@gikf

gikf commented Jul 13, 2022

Copy link
Copy Markdown
Member Author

Error in https://github.com/freeCodeCamp/chapter/runs/7315660461?check_suite_focus=true is a bit funny. I think it occurs, because cy.waitUntilMail doesn't wait enough, and aliases just the first email to allMail.

@ojeytonwilliams

Copy link
Copy Markdown
Contributor

@gikf Cypress worked fine locally, so I restarted CI. 🤞

@gikf

gikf commented Jul 13, 2022 •

Copy link
Copy Markdown
Member Author

I was able to get it locally as well. Once every few runs. Specifically with chromium.

@ojeytonwilliams

Copy link
Copy Markdown
Contributor

Okay, I'll see if I can reproduce it.

@ojeytonwilliams

Copy link
Copy Markdown
Contributor

@gikf I think your diagnosis was correct - sometimes waitUntilMail would find some mail before the new set of emails had been sent and use that as allMail.

By clearing before checking that should never happen.

@gikf

gikf commented Jul 13, 2022

Copy link
Copy Markdown
Member Author

Huh, that solution is a bit weird 😃, thanks for it nevertheless.

Comment thread server/src/services/MailerService.ts Resolved
Comment thread cypress/e2e/unsubscribe.cy.js Resolved
Comment thread server/src/services/UnsubscribeToken.ts Resolved
Comment thread server/src/services/UnsubscribeToken.ts Resolved
Comment thread server/src/services/UnsubscribeToken.ts Outdated
Comment on lines +5 to +8
export enum unsubscribeType {
Chapter,
Event,
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Now it crossed my mind whether shouldn't there be added values to these enums, to ensure they stay consistent in future (ie. in case of adding instance unsubscribing, or just in general).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

They should have specific values, yeah, since their values lose their associated types when they're packaged up into tokens. And, well, it's less of a headache if token has a consistent structure and values, even if we knew how they were changing.

Also, nitpick: enums are conventionally PascalCase.

@allella

allella commented Jul 15, 2022

Copy link
Copy Markdown
Contributor

@ojeytonwilliams I'm assuming the new unsubscribe link doesn't require logging in, which still would allow someone else to unsubscribe if the person happened to forward the event email.

Even if for post-MVP, do we want to send a confirmation email "You've been unsubscribed. We this a mistake, if so you can undo this action?"

and/or would we want to put a warning note on the top or bottom of emails that use any sort of token to warn people of the risks of sharing?

@ojeytonwilliams

Copy link
Copy Markdown
Contributor

Even if for post-MVP, do we want to send a confirmation email "You've been unsubscribed. We this a mistake, if so you can undo this action?"

I'm not sure we do, honestly. If someone doesn't want email, then sending them a confirmation email is probably not the way to go. We could show them a resubscribe page with that same info, though.

and/or would we want to put a warning note on the top or bottom of emails that use any sort of token to warn people of the risks of sharing?

The only token we should be sending via email is this one due to the risk that someone accidentally shares it.

As for whether or not we should warn people, I'm not sure. If we want to mitigate the downsides of sharing, I think it makes sense to have each token only work once. If we do that, then all you have to do is resubscribe once and stop sharing emails to the wrong people.

For instance, we could have an unsubscribeId in the db that gets regenerated each time the user subscribes. That doesn't feel MVP worthy, though.

This should differentiate it from the other email variables
@ojeytonwilliams

Copy link
Copy Markdown
Contributor

@gikf since I picked a slightly too generic name for the secret, I went ahead and changed it.

@ojeytonwilliams
ojeytonwilliams enabled auto-merge (squash) July 18, 2022 14:44

@ojeytonwilliams ojeytonwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

Another MVP issue down 🚀

Awesome work @gikf!

@ojeytonwilliams
ojeytonwilliams merged commit 3eecd86 into freeCodeCamp:main Jul 18, 2022
@gikf
gikf deleted the feat/unsubscribe-link branch July 18, 2022 16:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants