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

Enhance Notification Settings Logic for User Entity Updates in CouchDB #2723

Open
6 of 7 tasks
Tracked by #1055
Ayush8923 opened this issue Dec 16, 2024 · 6 comments · May be fixed by #2752
Open
6 of 7 tasks
Tracked by #1055

Enhance Notification Settings Logic for User Entity Updates in CouchDB #2723

Ayush8923 opened this issue Dec 16, 2024 · 6 comments · May be fixed by #2752
Assignees
Labels
Type: Feature new user-facing feature
Milestone

Comments

@Ayush8923
Copy link
Contributor

Ayush8923 commented Dec 16, 2024

Objective
This issue involves refining the notification settings logic and ensuring seamless synchronization with CouchDB. The following tasks are outlined:

Proposed Solutions & Alternatives

  • Update Notification Logic:
    • Implement logic to allow users to select any entity and define the corresponding notification conditions. These conditions should be saved and updated in the User entity in CouchDB.

  • Database Schema Example
    Below is an example of the expected schema for a NotificationConfig entity after notification settings are applied:
{
    "_id": "NotificationConfig:<user-uuid>",
    "_rev": "2-f9e14ee88f8107bd3a7bd5ec82f40fa4",
    "created": {
        "at": "2024-01-08T17:45:16.529Z",
        "by": "User:demo"
    },
    "updated": {
        "at": "2024-01-08T17:45:16.529Z",
        "by": "User:demo"
    },
    "notificationTypes": [
        {
            "entityType": "User",
            "conditions": {
                "field": "name",
                "operator": "eq",
                "value": "Anilaabh"
            },
            "isNotificationEnabled": true
        },
        {
            "entityType": "Task",
            "conditions": {
                "field": "name",
                "operator": "eq",
                "value": "Anilaabh"
            },
            "isNotificationEnabled": true
        }
    ]
}

  • Push Notification Toggle Logic:

    • Ensure that when the user enables or disables push notifications from the "Where you receive notifications" section in the notification settings page, the notificationsEnabled field in CouchDB's User entity is updated accordingly.
  • Add/Delete Notification Rules:

    • Implement logic to handle the addition and deletion of notification rules. When rules are added or removed, ensure the data is consistently updated in the User entity in CouchDB.
  • The Save button should be enabled only if any changes are made to the notification settings.

  • Retrieve and Update UI:

    • Fetch all notification rules associated with the user and update the UI dynamically to reflect these rules.
  • Update the Notification rule condition UI(maybe need to add the operator field) and based on that user can set the condition accordingly. Configure rules/filters for "entity update notifications" as an admin #2775

@Ayush8923 Ayush8923 added the Type: Feature new user-facing feature label Dec 16, 2024
@github-project-automation github-project-automation bot moved this to Triage / Analysis in All Tasks & Issues Dec 16, 2024
@Ayush8923 Ayush8923 moved this from Triage / Analysis to Planned (current "sprint") in All Tasks & Issues Dec 16, 2024
@Ayush8923 Ayush8923 removed the status in All Tasks & Issues Dec 16, 2024
@Ayush8923 Ayush8923 moved this to Planned (current "sprint") in All Tasks & Issues Dec 16, 2024
@Ayush8923 Ayush8923 self-assigned this Dec 16, 2024
@Ayush8923 Ayush8923 added this to the Notifications milestone Dec 16, 2024
@sleidig
Copy link
Member

sleidig commented Dec 16, 2024

Just one remark here, @Ayush8923 : The configuration should be stored as its own EntityType (maybe "NotificationConfig:<user_uuid>" or whatever name you suggest as more fitting).
We recently have moved away from combining any different data into one entity for various reasons and not every customized system even has a "User" entity type now.

@Ayush8923
Copy link
Contributor Author

Just one remark here, @Ayush8923 : The configuration should be stored as its own EntityType (maybe "NotificationConfig:<user_uuid>" or whatever name you suggest as more fitting). We recently have moved away from combining any different data into one entity for various reasons and not every customized system even has a "User" entity type now.

Thanks for this remark @sleidig. I have updated the draft database schema in the issue description. Please take a look once and let me know if there are any changes needed.

@sleidig
Copy link
Member

sleidig commented Dec 23, 2024

as per group discussion:

{
    "_id": "NotificationConfig:<userId (Keycloak ID)>",
    "_rev": ...,
    "created": ...,
    "updated": ...,
    "channels": { "push": true, "email": false }, 
    "notificationTypes": [
        {
            "notificationType": "entity-update", // in the future also e.g. "new_app_release"
            "enabled": true,
            "channels": { "push": true, "email": false }, 
            "entityType": "User",
            "conditions" // as <DataFilter/MongoQuery>, see https://www.mongodb.com/docs/manual/reference/operator/query/
        },
        {
            "entityType": "Task",
            "conditions": {
                "authors": { "$in": "<userId>" },
            }
        }
    ]
}

@Ayush8923 Ayush8923 moved this from Planned (current "sprint") to In Progress in All Tasks & Issues Dec 26, 2024
@Ayush8923 Ayush8923 linked a pull request Dec 26, 2024 that will close this issue
3 tasks
@Ayush8923
Copy link
Contributor Author

Ayush8923 commented Dec 27, 2024

@sleidig @tomwwinter @george-neha, In the notification setting page, I have created an initial UI(attached screenshot below) for the notification condition field. In this UI, the user first selects an entity type and then the user adds the corresponding fields (e.g., subject, name, etc.) with which the user wants to perform the comparison. Then the user selects an operator (e.g., Equals, Greater than, etc.) and specifies a value for the comparison in the notification condition.

Please check this initial UI and share your inputs or suggestions. Also, please let me know if I have missed anything.

Screenshot 2024-12-27 at 7 19 26 PM

@sleidig
Copy link
Member

sleidig commented Dec 27, 2024

We should support multiple conditions (so probably similar to the "add new notification rule" button, we can have a "add condition" button to add another block of this). Accordingly, I would move the condition fields to a second row in the box and maybe make that expandable/collapsible for easier overview of all rules.

A general thought coming to my mind: These conditions are actually similar (or probably the same?) as the filters to filter entries in the EntityList views. Can we reuse those UI components to filter data for the notification conditions instead of introducing a new model?

@Ayush8923
Copy link
Contributor Author

We should support multiple conditions (so probably similar to the "add new notification rule" button, we can have a "add condition" button to add another block of this). Accordingly, I would move the condition fields to a second row in the box and maybe make that expandable/collapsible for easier overview of all rules.

A general thought coming to my mind: These conditions are actually similar (or probably the same?) as the filters to filter entries in the EntityList views. Can we reuse those UI components to filter data for the notification conditions instead of introducing a new model?

Yes, I agree with the idea of supporting multiple conditions. Implementing an Add Condition button (maybe we can add the plus icon) for each rule will make the feature more flexible.

Yes, Instead of creating a new component, we can use the existing EntityList filter components for notification conditions. I’ll check the current filter implementation to evaluate how it can be adapted or extended for this use case.

@Ayush8923 Ayush8923 moved this from In Progress to Technical Review in All Tasks & Issues Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature new user-facing feature
Projects
Status: Technical Review
Development

Successfully merging a pull request may close this issue.

2 participants