Enhance notification entity and service for improved delivery channel handling
- Introduced new event types for notifications, including email and push, to support a broader range of delivery methods. - Added a `persistedEventType` function to map delivery channels to their corresponding event types, improving clarity and maintainability. - Updated the `sendToRecipient` method to ensure in-app notifications are always persisted, enhancing the reliability of notification records. - Improved error logging for in-app notification persistence failures, providing better context for debugging. This update enhances the notification system's flexibility and reliability by supporting multiple delivery channels and improving error handling.
This commit is contained in:
@@ -28,8 +28,26 @@ const (
|
||||
DeliveryChannelInApp DeliveryChannel = "in_app"
|
||||
)
|
||||
|
||||
// EventTypeInApp identifies notifications stored for the in-app notification center.
|
||||
const EventTypeInApp = "in_app"
|
||||
// Persisted event types for stored notifications (admin list / notification center).
|
||||
const (
|
||||
EventTypeInApp = "in_app"
|
||||
EventTypeEmail = "email"
|
||||
EventTypePush = "push"
|
||||
)
|
||||
|
||||
// persistedEventType maps a delivery channel to the event_type stored in MongoDB.
|
||||
func persistedEventType(channel DeliveryChannel) (string, bool) {
|
||||
switch channel {
|
||||
case DeliveryChannelEmail:
|
||||
return EventTypeEmail, true
|
||||
case DeliveryChannelPush:
|
||||
return EventTypePush, true
|
||||
case DeliveryChannelInApp:
|
||||
return EventTypeInApp, true
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
// DeliveryStatus represents the delivery status of notification
|
||||
type NotificationStatus string
|
||||
|
||||
Reference in New Issue
Block a user