get notification fix

This commit is contained in:
m.nazemi
2026-04-15 15:53:51 +03:30
parent 3d651f8596
commit 7145977250
2 changed files with 26 additions and 3 deletions
+15 -3
View File
@@ -201,7 +201,7 @@ func (s *notificationService) GetNotifications(ctx context.Context, req *SearchF
Seen: req.Seen,
Priority: req.Priority,
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 {
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
}
// Handle Link pointer - return nil if empty
var linkPtr *string
if notification.Link != "" {
linkPtr = &notification.Link
}
// Handle Image pointer - return nil if empty
var imagePtr *string
if notification.Image != "" {
imagePtr = &notification.Image
}
notificationsResponse = append(notificationsResponse, &NotificationResponse{
ID: notification.ID,
UserID: notification.UserID,
Recipient: recipient,
Title: notification.Title,
Message: notification.Message,
Link: &notification.Link,
Link: linkPtr,
Priority: notification.Priority,
Type: notification.Type,
EventType: notification.EventType,
@@ -248,7 +260,7 @@ func (s *notificationService) GetNotifications(ctx context.Context, req *SearchF
Metadata: notification.Metadata,
ScheduleAt: notification.ScheduledAt,
IsScheduled: notification.IsScheduled,
Image: &notification.Image,
Image: imagePtr,
Seen: notification.Seen,
SeenAt: notification.SeenAt,
ScheduledAt: notification.ScheduledAt,