get notification fix
This commit is contained in:
@@ -259,6 +259,17 @@ func (h *NotificationHandler) CustomerNotifications(c echo.Context) error {
|
|||||||
// Call service
|
// Call service
|
||||||
notifications, err := h.service.GetNotifications(c.Request().Context(), form, pagination)
|
notifications, err := h.service.GetNotifications(c.Request().Context(), form, pagination)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Log the actual error for debugging
|
||||||
|
c.Logger().Error("GetNotifications failed", map[string]interface{}{
|
||||||
|
"error": err.Error(),
|
||||||
|
"status": form.Status,
|
||||||
|
"priority": form.Priority,
|
||||||
|
"eventType": form.EventType,
|
||||||
|
"recipient": form.Recipient,
|
||||||
|
"limit": pagination.Limit,
|
||||||
|
"offset": pagination.Offset,
|
||||||
|
"page": (pagination.Offset / pagination.Limit) + 1,
|
||||||
|
})
|
||||||
return response.InternalServerError(c, "Failed to get notifications")
|
return response.InternalServerError(c, "Failed to get notifications")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ func (s *notificationService) GetNotifications(ctx context.Context, req *SearchF
|
|||||||
Seen: req.Seen,
|
Seen: req.Seen,
|
||||||
Priority: req.Priority,
|
Priority: req.Priority,
|
||||||
PerPage: pagination.Limit,
|
PerPage: pagination.Limit,
|
||||||
Page: pagination.Offset / pagination.Limit,
|
Page: (pagination.Offset / pagination.Limit) + 1, // Convert 0-based offset to 1-based page number
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.Error("Failed to get notifications", map[string]interface{}{
|
s.logger.Error("Failed to get notifications", map[string]interface{}{
|
||||||
@@ -233,13 +233,25 @@ func (s *notificationService) GetNotifications(ctx context.Context, req *SearchF
|
|||||||
recipient = cust
|
recipient = cust
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle Link pointer - return nil if empty
|
||||||
|
var linkPtr *string
|
||||||
|
if notification.Link != "" {
|
||||||
|
linkPtr = ¬ification.Link
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle Image pointer - return nil if empty
|
||||||
|
var imagePtr *string
|
||||||
|
if notification.Image != "" {
|
||||||
|
imagePtr = ¬ification.Image
|
||||||
|
}
|
||||||
|
|
||||||
notificationsResponse = append(notificationsResponse, &NotificationResponse{
|
notificationsResponse = append(notificationsResponse, &NotificationResponse{
|
||||||
ID: notification.ID,
|
ID: notification.ID,
|
||||||
UserID: notification.UserID,
|
UserID: notification.UserID,
|
||||||
Recipient: recipient,
|
Recipient: recipient,
|
||||||
Title: notification.Title,
|
Title: notification.Title,
|
||||||
Message: notification.Message,
|
Message: notification.Message,
|
||||||
Link: ¬ification.Link,
|
Link: linkPtr,
|
||||||
Priority: notification.Priority,
|
Priority: notification.Priority,
|
||||||
Type: notification.Type,
|
Type: notification.Type,
|
||||||
EventType: notification.EventType,
|
EventType: notification.EventType,
|
||||||
@@ -248,7 +260,7 @@ func (s *notificationService) GetNotifications(ctx context.Context, req *SearchF
|
|||||||
Metadata: notification.Metadata,
|
Metadata: notification.Metadata,
|
||||||
ScheduleAt: notification.ScheduledAt,
|
ScheduleAt: notification.ScheduledAt,
|
||||||
IsScheduled: notification.IsScheduled,
|
IsScheduled: notification.IsScheduled,
|
||||||
Image: ¬ification.Image,
|
Image: imagePtr,
|
||||||
Seen: notification.Seen,
|
Seen: notification.Seen,
|
||||||
SeenAt: notification.SeenAt,
|
SeenAt: notification.SeenAt,
|
||||||
ScheduledAt: notification.ScheduledAt,
|
ScheduledAt: notification.ScheduledAt,
|
||||||
|
|||||||
Reference in New Issue
Block a user