diff --git a/internal/notification/service.go b/internal/notification/service.go index 8bb79cd..ed8821a 100644 --- a/internal/notification/service.go +++ b/internal/notification/service.go @@ -50,12 +50,22 @@ func NewService( // Send sends a multiple notification func (s *notificationService) Send(ctx context.Context, req *NotificationRequest) error { + image := "" + if req.Image != nil { + image = *req.Image + } + + link := "" + if req.Link != nil { + link = *req.Link + } + s.logger.Info("Sending notification", map[string]interface{}{ "recipient": req.Recipient, "type": req.Type, "priority": req.Priority, - "link": req.Link, - "image": req.Image, + "link": link, + "image": image, }) if req.Target == TargetAudienceAllUsers || req.Target == TargetAudienceSpecificUsers { @@ -73,8 +83,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest Type: string(req.Type), Priority: string(req.Priority), EventType: notification.EventTypePush, - Link: *req.Link, - Image: *req.Image, + Link: link, + Image: image, Metadata: map[string]any{ "tender": strings.TrimSpace(req.Tender), }, @@ -96,8 +106,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest Type: string(req.Type), Priority: string(req.Priority), EventType: notification.EventTypeEmail, - Link: *req.Link, - Image: *req.Image, + Link: link, + Image: image, Metadata: map[string]any{ "tender": strings.TrimSpace(req.Tender), }, @@ -124,8 +134,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest Type: string(req.Type), Priority: string(req.Priority), EventType: notification.EventTypePush, - Link: *req.Link, - Image: *req.Image, + Link: link, + Image: image, Methods: notification.NotificationMethods{ Push: v, }, @@ -146,8 +156,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest Type: string(req.Type), Priority: string(req.Priority), EventType: notification.EventTypeEmail, - Link: *req.Link, - Image: *req.Image, + Link: link, + Image: image, Methods: notification.NotificationMethods{ Email: recipient.Email, },