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

feat: auto subscribe switch - #1593

Merged
ojeytonwilliams merged 30 commits into
freeCodeCamp:mainfrom
gikf:feat/auto-subscribe
Nov 2, 2022
Merged

ojeytonwilliams merged 30 commits into
freeCodeCamp:mainfrom
gikf:feat/auto-subscribe

Conversation

@gikf

@gikf gikf commented Sep 23, 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.

  • Adds option in profile to change the Automatic chapter subscription.
  • When true:
    • Subscribes to chapter when joining it.
    • Subscribes to event when RSVPing. (Currently regardless of the individual chapter subscription).
  • When false:
    • Doesn't subscribe to chapter when joining it.
    • Subscribing to event depends on chapter subscription. If chapter subscription was manually changed to true, user will be subscribed to event when RSVPing.
  • Subscription to chapters already joined and RSVPed events is not affected.

@gitpod-io

gitpod-io Bot commented Sep 23, 2022

Copy link
Copy Markdown

@ghost

ghost commented Sep 23, 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

@gikf
gikf force-pushed the feat/auto-subscribe branch from f9c86fc to 6d81bca Compare September 23, 2022 10:02
@gikf
gikf marked this pull request as ready for review September 26, 2022 20:22
@gikf
gikf requested a review from a team September 26, 2022 20:22

@Sboonny Sboonny left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When reviewing, I noticed that profiles isn't sectioned, so it's hard to distinguish what something is for, and it feels chaotic.

But this is for a different pull request, I didn't find issues, only small nitpick which I am okay with this going through with dismissing as well.

Edit: I meant this as a comment, not as approval sorry for the confusion 🤦 😅

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

More of a question than a suggestion, but what do you think to including auto_subscribe updates in updateMe? It cuts down on the number of resolvers, hooks and so on.

ctx.user.user_chapters.find(
(user_chapter) => user_chapter.chapter_id === chapterId,
)?.subscribed ?? true;
)?.subscribed || ctx.user.auto_subscribe;

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.

Suggested change
)?.subscribed || ctx.user.auto_subscribe;
)?.subscribed ?? ctx.user.auto_subscribe;

Otherwise if subscribed is false then this will fall back to auto_subscribe.

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.

Generally that was the idea, when auto_subscribe === true, it subscribes when joining chapters and RSVPing to event. Regardless of the chapterUser.subscribed of the event's chapter.

But it can be changed to give chapterUser.subscribed precedence. In such case actually auto_subscribe won't be needed here at all, as chapterUser is always created before eventUser.

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.

Ah, right. So, this is a tricky one because it's important to avoid sending emails when a user thinks they've unsubscribed. But it's also important that we have sensible defaults.

As a user, when I unsubscribe from a Chapter, I expect that Chapter to stop communicating with me. However, if I then RSVP to an Event, do I want notifications about that specific Event, even though I don't want them from the Chapter generally? Maybe, but I think we need to let people opt-in.

Another issue with the existing logic is how we communicate what it does. We'd have to say something like

Automatically enable email notifications when you join a chapter or RSVP to an event (even if you are not subscribed to the chapter hosting that event).

vs.

Automatically enable email notifications from a chapter when you join.

Since we really want to encourage users to turn on notifications, I think it's important that the setting that does is transparent.

@allella allella Sep 29, 2022 •

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.

I feel like the RSVP notifications and chapter notifications shouldn't impact each other.

If someone turns off chapter.subscribed, then they are turning off new event announcements, general announcements, and anything else an organizer might send to everyone. I don't think that would disable RSVP related email notifications just like it wouldn't un-RSVP a person from an event.

@ojeytonwilliams 's suggestion to add labels to make things clear is probably the only way we can avoid confusion.

Just a first pass at it

Chapter Page
Would you like to turn off email updates for new event and general announcements for this Chapter?

RSVP Page / Form
Would you like to stop all email updates for this event, including changes and cancellations?

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.

Actually, I updated the suggestions so both are asking about disabling emails, like "turn off" and "stop". We could very well make them both affirmative, like "enable" and "turn on", but it's probably good to do things in a similar format.

I guess it depends on the form element being used and even the current state of the element. Like, could we change the language of the label based on the state? For example, if it's on, then ask "Would you like to turn off". If it's off, then ask "Would you like to turn on?".

Since we're talking about "Switches" I wanted to repost the earlier conversation about form element selection and about toggling notifications on and off as it was related to emails. It looks like we even explored the use of the word "Follow {Chapter Name}" instead of "Subscribe" vs "Unsubscribe". I'm not suggesting we change the schema, just that we might use words for the user that help add to the context.

Facebook uses "Follow" and Meetup uses "Join" and the current UI has "Subscribe" vs "Unsubscribe".

One somewhat confusing thing is when you toggle "Subscribe" on it says "member of the chapter". So, does that mean if you unsubscribe that you're no longer a member? I'd imagine you can be a member of the group, and just not get notifications, but that may open a can of worms for the MVP.

#107 (comment)
#107 (comment)
https://mui.com/material-ui/react-switch/#switches-with-formcontrollabel
#107 (comment)

@allella allella Sep 29, 2022 •

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.

Also, given the types of custom switch designs where you have "On" and "Off", perhaps using a question format for a label, like I suggested above, isn't good with switches.

I know we're using Chakra, but the Material UI docs show what you can do with custom switches like having a checkmark in the switch, or the "On" and "Off" labels.

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.

@allella that's a good point about the separation between Chapter and Event notifications. If we make it clear what turning off Chapter notifications does, then it's probably fine to have clicking on RSVP to tacitly accept that you're going to get emails about that Event.

We will need to make this configurable sooner rather than later, though not necessarily for the MVP.

Also, though I've not tested this properly, certain notifications are sure to overlap with the notifications coming from Google Calendar. We'll have to experiment a bit to make sure users can get the emails they want.

I know we're using Chakra, but the Material UI docs show what you can do with custom switches like having a checkmark in the switch, or the "On" and "Off" labels.

We should be careful we don't customize switches too much, but something like what you shared below looks good. I don't know how straightforward that would be to implement, though.

Finally, I'm not sure which word (follow or subscribe) works best. That might be something we discover through user testing.

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.

So, for this PR, I think the consensus is the following.

  • Chapter subscription should control if a user gets new event notifications
  • Events should be subscribed to when a user clicks RSVP, regardless of Chapter subscription

We can handle further notification configuration separately (maybe post MVP).

@gikf @allella does that sound about right?

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.

For MVP, I'd agree new event notifications are the minimum. If / when organizers & admin can send an email to all Chapter members for a general announcements, then that would seem to fit under "subscribed to chapter notifications", at least until we break the controls down to smaller bits.

Part of our challenge with the switches for MVP is there may be more than one thing it turns on or off, as with the new events & general announcements example for a chapter.

Eventually, we can have more controls to allow a user / member to be more granular about their notification preferences, as in the screenshots of Facebook and Meetup examples.

For the RSVP, it looks like we don't give the member the option to turn off RSVP-related notifications until after they have hit the RSPV confirmation button.
image
That's fine, but eventually it may make sense to have the RSVP form with other options (media waiver, food preferences, and such, and that interface might also make sense to toggle on/off the RSVP notifications.

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.

To be honest I'm still not sure what to do with how auto subscribe works for events.

What I'm sure is that currently, when unsubscribing from chapter, user is also unsubscribed from events in that chapter. Because that should be slightly outside of this PR scope, I've created issue - #1639


  • Chapter subscription should control if a user gets new event notifications

That's how it is, I believe. User has to be subscribed to chapter to receive emails about newly created events.

  • Events should be subscribed to when a user clicks RSVP, regardless of Chapter subscription

As I understand this, it means always subscribing to events when RSVPing.


const isSubscribedToEvent = userChapter ? userChapter.subscribed : true; // TODO add default event subscription setting override
const isSubscribedToEvent =
userChapter?.subscribed || ctx.user.auto_subscribe;

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.

Suggested change
userChapter?.subscribed || ctx.user.auto_subscribe;
userChapter?.subscribed ?? ctx.user.auto_subscribe;

Same principle.

@Sboonny

Sboonny commented Sep 27, 2022 •

Copy link
Copy Markdown
Member

Btw random question, should this function starts as false?

Because we don't have an indication that this function exist, so people may be subscribing to email services without knowing, and we may be flagged as spam in the future.

Edit: maybe that what RSVP means, if so you can ignore me.

@ojeytonwilliams

Copy link
Copy Markdown
Contributor

@Sboonny yeah, that's a very good point. People need to opt-in to receiving email, so we'll need to have this default to false and do something similar to the main repo. That is to say, when people sign up for the first time, we should give them the option to receive emails from Chapter.

Edit: maybe that what RSVP means, if so you can ignore me.

Nope, you will get notified (by email) about new events so that you can decide to go (which you do by RSVPing).

@gikf

gikf commented Sep 27, 2022

Copy link
Copy Markdown
Member Author

I'm going to pull it into updateMe and flip the default to false.

@allella

allella commented Sep 29, 2022

Copy link
Copy Markdown
Contributor

Not that I'm suggesting this is MVP, but here's how other sites deal with the complexity of "belonging to a group" vs "getting notifications from the group" (via a series of switches)

Meetup Example

image
and clicking "Group Notifications" goes to
image

Facebook Example

image

image

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

Just some nitpicks:

Comment thread server/src/controllers/User/input.ts Outdated
Comment on lines +5 to +7
export class UpdateUserInputs
implements Omit<User, 'id' | 'email' | 'auto_subscribe'>
{

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.

Suggested change
export class UpdateUserInputs
implements Omit<User, 'id' | 'email' | 'auto_subscribe'>
{
export class UpdateUserInputs implements Omit<User, 'id' | 'email'> {

We're using this, so there's no need to omit it.

},
});

const eventSubscription = true;

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.

Suggested change
const eventSubscription = true;

This seems redundant, now.

rsvp: { connect: { name: newRsvpName } },
event_role: { connect: { name: 'member' } },
subscribed: isSubscribedToChapter,
subscribed: eventSubscription,

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.

Suggested change
subscribed: eventSubscription,
subscribed: true,

// NOTE: this relies on there being an event_user record, so must follow
// that.
if (newRsvpName !== 'waitlist' && isSubscribedToChapter) {
if (newRsvpName !== 'waitlist' && eventSubscription) {

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.

Suggested change
if (newRsvpName !== 'waitlist' && eventSubscription) {
if (newRsvpName !== 'waitlist') {

@ojeytonwilliams

Copy link
Copy Markdown
Contributor

I blocked this because it requires a db migration and I've not set up the workflows for that yet.

Co-authored-by: Oliver Eyton-Williams <[email protected]>
<FormControl>
<Flex>
<FormLabel htmlFor="auto_subscribe">
Automatic chapter subscription

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.

Suggested change
Automatic chapter subscription
Subscribing when joining chapters

This is really tricky to word correctly, but this is my best attempt so far.

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.

I have two ideas going in a slightly different direction:

  • Default chapter subscription
  • Subscribe to chapters by default

What do you think? The helper text suggestion would work with these too.

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.

You know what, I think "Subscribe to chapters when joining them" might be the way to go. It's a bit verbose, but it at least gets across the point that 'joining' and 'subscribing' are two different things.

I've spent far too long thinking about this, though!

Comment on lines +108 to +109
? 'Automatically subscribe to chapter when joining it and receive emails about new events in chapter.'
: "Don't automatically subscribe to joined chapters."}

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.

Suggested change
? 'Automatically subscribe to chapter when joining it and receive emails about new events in chapter.'
: "Don't automatically subscribe to joined chapters."}
? '(After joining a new chapter, you will be notified when new events are created.)'
: '(After joining a new chapter, you will not be notified about new events unless you subscribe.)'}

This way the information is describing the current state, rather than what will be the case once you click the button. I believe this is the most common pattern

@ojeytonwilliams

Copy link
Copy Markdown
Contributor

Awesome, thanks @gikf. Did you have any issues creating the migration?

Anyways, I'll get this in before I have second thoughts about the wording.

@ojeytonwilliams
ojeytonwilliams merged commit e6345a1 into freeCodeCamp:main Nov 2, 2022
@gikf

gikf commented Nov 2, 2022

Copy link
Copy Markdown
Member Author

@ojeytonwilliams Dunno if this was expected on the first run, but I had to use migrate reset initially, otherwise the migrate dev was finding dozens of changes.

@gikf
gikf deleted the feat/auto-subscribe branch November 2, 2022 15:11
@ojeytonwilliams ojeytonwilliams mentioned this pull request Nov 3, 2022
3 tasks done
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