TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
988 stars 310 forks source link

Support user notification preferences #7308

Open KrishnaIyer opened 2 months ago

KrishnaIyer commented 2 months ago

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

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

UX

Contributing

Validation

Code of Conduct

KrishnaIyer commented 2 months ago

@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 commented 2 months ago

@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 commented 2 months ago

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 commented 1 month ago

@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 commented 1 month ago

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.

ryaplots commented 1 month ago

@KrishnaIyer In the notifyAdminsInternal() method, can we just ignore the req.Email field that will be deprecated and the allowed notification types as well? This method is only used for user_requested and client_requested types and these notifications should always send emails to admins, so we don't need to check if the user allows the notification types.

KrishnaIyer commented 1 month ago

@KrishnaIyer In the notifyAdminsInternal() method, can we just ignore the req.Email field that will be deprecated and the allowed notification types as well? This method is only used for user_requested and client_requested types and these notifications should always send emails to admins, so we don't need to check if the user allows the notification types.

Yes I think that makes sense.

pierrephz commented 1 month ago

Email notification wireframe:

  1. Access the Email notification settings in the side bar under User settings
  2. Find the list of preferences (For admin, some are disabled if they require their actions)
  3. After editing, save or discard and receive a feedback from the system

We can still discuss the list of preferences, for example, I am not sure that Temporary password should be an option there as you will always receive an email for that.

Screenshot 2024-10-15 at 15 25 50
ryaplots commented 2 weeks ago

I am not sure the wireframe is correct. Do we need options for notifications like validate or login token? Also the descriptions don't seem correct as an API key can be changed for different entities and not only apps. @KrishnaIyer can you double check?

I have opened a draft PR with fixed descriptions and included only the necessary notifications - https://github.com/TheThingsNetwork/lorawan-stack/pull/7363

cc: @KrishnaIyer @pierrephz let me know if it's good

KrishnaIyer commented 2 weeks ago

@ryaplots: These are just examples. You can adapt it to the list of options that we actually provide. If you need help in drafting text for each of the options, let me know.