Skip to content
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

Support user notification preferences #7308

Open
3 of 25 tasks
KrishnaIyer opened this issue Sep 16, 2024 · 5 comments
Open
3 of 25 tasks

Support user notification preferences #7308

KrishnaIyer opened this issue Sep 16, 2024 · 5 comments
Assignees
Labels
c/console This is related to the Console c/identity server This is related to the Identity Server needs/ux This needs UX design / approval
Milestone

Comments

@KrishnaIyer
Copy link
Member

KrishnaIyer commented Sep 16, 2024

Summary

Support user notification preferences. Replaces https://github.com/TheThingsIndustries/lorawan-stack/issues/3280

Current Situation

Currently users receive emails for all notification types except collaborator_changed. We want to allow users to choose what kind of emails they receive.
All notifications are displayed in the console. So some users prefer to not receive emails

Why do we need this? Who uses it, and when?

We want to allow users to choose what kind of emails they receive.

Proposed Implementation

Backend

  • Introduce a new Enum for NotificationType in the API. Currently we use hardcoded strings like user_requested or collaborator_changed in pkg/email/templates and when we use the CreateNotificationRequest message.
    • We need to do a replacement in all the places where this is used and also test that email templates are not affected by this.
  • Introduce a NotificationPreferences message inside the User message.
    • This contains a single message repeated NotificationType email_notification_types. This is a list of NotificationType for which we would send emails.
    • This can be updated by the User based to select which notifications they want emails for. We need some validation to filter out duplicates.
    • There are special admin emails user_requested and client_requested, both of which require admin actions. These emails are very infrequent and should not be skipped. So the API should either ignore these enums or return a validation error.
  • Add DB entries and migrations.
  • Change the lookupNotificationReceivers function to return a second emailReceiverIDs argument. This is a filtered list of receiver IDs.
    • A receiver is placed in this list if the email notification type in req is allowed for the user in their preferences.
  • In CreateNotification, call is.SendNotificationEmailToUserIDs only emailReceiverIDs is not empty.
  • Deprecate the email field of the Notification message. We should instead get this from the user preferences
  • Lots of unit and production testing

The backend needs to target the v3.33 branch since this requires a database migration.

UX

  • Edit the /console/user-settings/profile view and rename it to Account or Preferences, whichever makes sense.
  • Add a new "Email Notifications" section.
    • This contains a list of checkboxes, similar to choosing Rights on API keys. Example below
      Screenshot 2024-09-16 at 16 15 32
    • The options are the NotificationType enums.
    • We also somehow have an option to choose All or None.
    • Let's document here that emails that require admin actions such as approving users or OAuth clients cannot be skipped.
  • Plug this page into the API above and test.

Contributing

  • I can help by doing more research.
  • I can help by implementing the feature after the proposal above is approved.
  • I can help by testing the feature before it's released.

Validation

Code of Conduct

@KrishnaIyer KrishnaIyer added c/console This is related to the Console c/identity server This is related to the Identity Server needs/ux This needs UX design / approval labels Sep 16, 2024
@KrishnaIyer KrishnaIyer added this to the v3.33.0 milestone Sep 16, 2024
@github-actions github-actions bot added the needs/triage We still need to triage this label Sep 16, 2024
@KrishnaIyer KrishnaIyer modified the milestones: v3.33.0, v3.32.2 Sep 16, 2024
@KrishnaIyer
Copy link
Member Author

@nicholaspcr: Please let me know if the backend part makes sense?

@pierrephz: Can you think of a draft wireframes for the UX? Please ping me if you have doubts.

@nicholaspcr
Copy link
Contributor

@nicholaspcr: Please let me know if the backend part makes sense?

Looks pretty good to me but I do have a question, would it be more efficient to have a NotificationsFilters instead of NotificationsPreferences? That way what we are storing on the user are only the notification types which have to be filtered.

Additionally I believe its easier for users to set what they don't want rather than the opposite.

@KrishnaIyer
Copy link
Member Author

Looks pretty good to me but I do have a question, would it be more efficient to have a NotificationsFilters instead of NotificationsPreferences? That way what we are storing on the user are only the notification types which have to be filtered.

The question here is the difference of what the default behavior is,
a. Do users receive all emails by default and they choose what not to receive? (OR)
b. Do users receive no emails by default and they can enable it for certain ones?

User experience-wise, (b) is better since all notifications are available in the Console by default.

@ryaplots
Copy link
Contributor

@KrishnaIyer @nicholaspcr @pierrephz Considering that user_requested and client_requested require admin actions, they should be selected by default and the de-selection should be disabled in the UI. There should also be a message there saying that these require user action and that they are infrequent, so they cannot be opted out of. What do you think?
For the backend, I am not sure if it's best to ignore these or return an error. I would say error. In case one of these gets through, then it's nice to have some kind of feedback. Have them as "not allowed" options.

@KrishnaIyer
Copy link
Member Author

Considering that user_requested and client_requested require admin actions, they should be selected by default and the de-selection should be disabled in the UI.

I would say let's show it in a non-editable state in the console for admins only. For the API, I think we should just ignore this if it's set in the filters.

@KrishnaIyer KrishnaIyer removed the needs/triage We still need to triage this label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/console This is related to the Console c/identity server This is related to the Identity Server needs/ux This needs UX design / approval
Projects
None yet
Development

No branches or pull requests

4 participants