From 67b2058506521c1225c487de361ed2cce4ba4899 Mon Sep 17 00:00:00 2001 From: "n.nakhostin" Date: Sun, 21 Sep 2025 14:44:59 +0330 Subject: [PATCH] Refactor Notification Handler to Use Customer Context for User ID Retrieval - Updated the CustomerNotifications and PublicMarkSeen methods in NotificationHandler to retrieve the customer ID from context instead of the user ID, aligning with the new customer-centric approach. - This change enhances the integration between notifications and customer management, ensuring that notifications are correctly associated with customers. - Maintained existing error handling for missing customer ID, ensuring robustness in the notification retrieval process. --- internal/notification/handler.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/notification/handler.go b/internal/notification/handler.go index 9ba7c00..76afc93 100644 --- a/internal/notification/handler.go +++ b/internal/notification/handler.go @@ -4,6 +4,7 @@ import ( "github.com/asaskevich/govalidator" "github.com/labstack/echo/v4" + "tm/internal/customer" "tm/internal/user" "tm/pkg/logger" "tm/pkg/response" @@ -230,7 +231,7 @@ func (h *NotificationHandler) ViewNotification(c echo.Context) error { // @Security BearerAuth // @Router /api/v1/notifications [get] func (h *NotificationHandler) CustomerNotifications(c echo.Context) error { - userID, err := user.GetUserIDFromContext(c) + userID, err := customer.GetCustomerIDFromContext(c) if err != nil { return response.BadRequest(c, "User ID required", "User must be associated with a user") } @@ -274,7 +275,7 @@ func (h *NotificationHandler) CustomerNotifications(c echo.Context) error { func (h *NotificationHandler) PublicMarkSeen(c echo.Context) error { notificationID := c.Param("id") - userID, err := user.GetUserIDFromContext(c) + userID, err := customer.GetCustomerIDFromContext(c) if err != nil { return response.BadRequest(c, "User ID required", "User must be associated with a user") }