Notifications workflow, integration and documentation #208
Dynavy
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Notification system flow
Introduction:
The notification system in the Copay app backend is designed to keep users informed about important events related to their groups, expenses, and payments. Notifications are created when specific actions occur in the application , such as when a user is added to a group, when a group's estimated price is updated, when a payment is confirmed, etc...
Entity relationships:
The notification system is built around the following entities:
Notification: Represents a notification message sent to a user:
Fields: notification_id, user_id, message, is_read, created_at.
Relationships: Many-to-one with User.
User: Represents a user in the system:
Notification flow:
Creation clow:
An event occurs in the system that requires a notification (e.g., a user is added to a group).
The relevant service method calls the NotificationService.createNotification method.
The NotificationService creates a new Notification entity with:
The target user.
A descriptive message.
is_read set to false.
The current timestamp.
The notification is saved to the database
Retrieval flow:
A user requests their notifications.
The NotificationService retrieves the notifications from the database through NotificationService.getNotificationsByUserId method.
The notifications are converted to DTOs and returned to the user.
Notification use cases:
The following events trigger notifications in the system:
Group Management
Group creation:
When a user creates a group, all invited registered members receive a notification.
Message: "You have been added to group '{groupName}' by {creatorUsername}".
Adding members to a group:
When a user is added to an existing group, they receive a notification.
Message: "You have been added to group '{groupName}' by {creatorUsername}".
Updating group estimated price:
When a group's estimated price is updated, all registered members (except the group creator) receive a notification.
Message: "The estimated price for group '{groupName}' has been updated to {newPrice} {currency}".
Payment management:
Payment confirmation:
When a payment is confirmed, the debtor user receives a notification.
Message: "Your payment of {amount} in group '{groupName}' has been confirmed".
Notification system diagram:
Implementation details:
Notification entity:
Notification service:
The NotificationService provides methods for:
Creating notifications.
Retrieving notifications for a user.
Marking notifications as read.
Counting unread notifications.
Deleting notifications.
Integration points:
Notifications are integrated at key points in the application:
GroupServiceImpl:
createGroup() method.
updateGroupEstimatedPrice().
addNewRegisteredMembers().
PaymentConfirmationServiceImpl:
requestPayment().
markPaymentAsConfirmed().
This ensures users are kept informed about important events related to their groups and payments.
Beta Was this translation helpful? Give feedback.
All reactions