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

Store and access notifications & mark them "read" #2690

Closed
8 tasks done
Tracked by #1055
sleidig opened this issue Nov 28, 2024 · 6 comments · Fixed by #2738
Closed
8 tasks done
Tracked by #1055

Store and access notifications & mark them "read" #2690

sleidig opened this issue Nov 28, 2024 · 6 comments · Fixed by #2738
Assignees
Milestone

Comments

@sleidig
Copy link
Member

sleidig commented Nov 28, 2024

For the "notification centre" UI, it is necessary to store notification events in the same way as the user-facing functionalities:

DISCUSS:

  • Do we store events in CouchDB as "normal" entities, reusing our existing architecture? Or do we store these completely different?
  • Is an event record specific for a single user or are these "global" events, that are viewed by all users who have activated that type of notification?

We need to implement the below-mentioned functionality in the notification list.

  • Display all notifications in the All tab.
  • Show only unread notifications in the Unread tab.
  • When a user clicks on the three dots and selects "Mark as Read," the notification's readStatus should be updated to true for that user.
  • When a user selects Delete Notification, the notification should be removed and no longer displayed in the notification list.
  • In the three-dot menu, selecting Enable notifications should activate the notification for the user.
  • In the three-dot menu, selecting Notification Settings should redirect the user to the Notifications tab within the Profile section. This is handled in this PR.
  • When the user clicks on the notification then the user will be redirect to the corresponding notification action URL.
  • When a user marks a notification as read or deletes it, the unread notification count should be updated accordingly.
@Ayush8923
Copy link
Contributor

Ayush8923 commented Nov 29, 2024

Do we store events in CouchDB as "normal" entities, reusing our existing architecture? Or do we store these completely different?

According to me, Notifications can be considered a new entity type within the system. Therefore, it makes sense to create a dedicated entity in CouchDB to handle them. For reference, I’ve included an example below of how we could structure a notification document in CouchDB:

{
  "_id": "NotificationEvent:01356934-75a0-4273-9c03-6e943da1bfbc",
  "_rev": "1-40873acc5cd6e56f0abc83686f29336f",
  "title": "Dummy Notification Title",
  "body": "This is a dummy notification body.",
  "actionURL": "http://localhost:4200",
   "notificationFor": "<user-uuid>",
  "fcmToken": "f6dmHHeKUM1Q_DfSCLmtl9:APA91bEgFmu2yUcMTzOr8CusfjWHTUPPvsVivuOX5pGAInhmPsLrEdAWsuPFBHjwNaLnrQWAjBXohvn1Mkb_fYHwIpIi3aBiOy9HudBWzytXDwwlbLwd66o",
  "readStatus": false,
  "created": {
    "at": "2024-12-03T19:06:07.076Z"
  },
  "updated": {
    "at": "2024-12-03T19:06:07.076Z"
  }
}

@sleidig @tomwwinter Please let me know what you think/suggest?

@Ayush8923
Copy link
Contributor

Is an event record specific for a single user or are these "global" events, that are viewed by all users who have activated that type of notification?

As far as I understand, event records are user-specific. Each user will have the ability to select the types of notifications they wish to receive. A new sidebar tab will be introduced, allowing users to define their preferences for different event types. From this tab, users can opt-in to notifications for specific event types, ensuring they are only notified about the events they have selected.

In the CouchDB user document, we can to add the following fields to manage this customization:

  1. notificationsEnabled: A boolean field indicating whether the user has enabled notifications.
  2. enabledNotificationTypes: An array field listing the event types for which the user has chosen to receive notifications.

@sleidig @tomwwinter Please let me know what you think/suggest?

@Ayush8923
Copy link
Contributor

Ayush8923 commented Dec 2, 2024

Is an event record specific for a single user or are these "global" events, that are viewed by all users who have activated that type of notification?

As far as I understand, event records are user-specific. Each user will have the ability to select the types of notifications they wish to receive. A new sidebar tab will be introduced, allowing users to define their preferences for different event types. From this tab, users can opt-in to notifications for specific event types, ensuring they are only notified about the events they have selected.

In the CouchDB user document, we can to add the following fields to manage this customization:

  1. notificationsEnabled: A boolean field indicating whether the user has enabled notifications.
  2. enabledNotificationTypes: An array field listing the event types for which the user has chosen to receive notifications.

@sleidig @tomwwinter Please let me know what you think/suggest?

@sleidig @tomwwinter, Here's an updated schema and approach for updating an existing CouchDB user document to include the new keys notificationsEnabled and enabledNotificationTypes.

{
  "_id": "User:Anilaabh",
  "_rev": "2-f9e14ee88f8107bd3a7bd5ec82f40fa4",
  "name": "Anilaabh",
  "paginatorSettingsPageSize": {},
  "created": {
    "at": "2024-01-08T17:45:16.529Z",
    "by": "User:demo"
  },
  "updated": {
    "at": "2024-01-08T17:45:16.529Z",
    "by": "User:demo"
  },
  "notificationsEnabled": true // This is the boolean field indicating whether the user has enabled the notifications or not.
  "enabledNotificationTypes": ["childer", "school"] // This is the event types field for which types of the event the user have chosen to receive the notification.
  "phone": "+919546945162"
}

@Ayush8923
Copy link
Contributor

Ayush8923 commented Dec 19, 2024

@sleidig We need to update the user document to include userNotificationsEnabled(This is used to check whether the user has enabled notifications for the app), but as far as I can check, we don't have a file for the user database entity. Should we create a new user database entity file for this, or is there another way to update the user document in CouchDB?

@sleidig
Copy link
Member Author

sleidig commented Dec 19, 2024

I think this can become a part of the NotificationConfig entity that you outlined here: #2723 ?

@Ayush8923
Copy link
Contributor

Yes this is part of the NotificationConfig entity, we can use the same database schema for saving/updating the userNotificationsEnabled value.

@Ayush8923 Ayush8923 moved this from In Progress to Functional Review in All Tasks & Issues Dec 26, 2024
@Ayush8923 Ayush8923 moved this from Functional Review to In Progress in All Tasks & Issues Dec 26, 2024
@Ayush8923 Ayush8923 moved this from In Progress to Technical Review in All Tasks & Issues Dec 27, 2024
@sleidig sleidig moved this from Technical Review to In Progress in All Tasks & Issues Dec 27, 2024
@sleidig sleidig closed this as completed Dec 27, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in All Tasks & Issues Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants