diff --git a/internal/http/graph/like_notification_resolvers.go b/internal/http/graph/like_notification_resolvers.go index ed0a804..0794dc2 100644 --- a/internal/http/graph/like_notification_resolvers.go +++ b/internal/http/graph/like_notification_resolvers.go @@ -5,7 +5,41 @@ import ( "fmt" ) -// GetLikeNotifications is the resolver for the getLikeNotifications field. +// MarkLikeNotificationAsRead is the resolver for the markLikeNotificationAsRead field. +func (r *mutationResolver) MarkLikeNotificationAsRead(ctx context.Context, notificationID int) (*MarkLikeNotificationReadResult, error) { + userID, err := getUserIDFromContext(ctx) + if err != nil { + return nil, fmt.Errorf("authentication required: %w", err) + } + + err = r.Services.Like.MarkLikeNotificationAsRead(ctx, notificationID, userID) + if err != nil { + return nil, fmt.Errorf("failed to mark notification as read: %w", err) + } + + return &MarkLikeNotificationReadResult{ + Success: true, + Message: "Notification marked as read successfully", + }, nil +} + +// MarkAllLikeNotificationsAsRead is the resolver for the markAllLikeNotificationsAsRead field. +func (r *mutationResolver) MarkAllLikeNotificationsAsRead(ctx context.Context) (*MarkLikeNotificationReadResult, error) { + userID, err := getUserIDFromContext(ctx) + if err != nil { + return nil, fmt.Errorf("authentication required: %w", err) + } + + err = r.Services.Like.MarkAllLikeNotificationsAsRead(ctx, userID) + if err != nil { + return nil, fmt.Errorf("failed to mark all notifications as read: %w", err) + } + + return &MarkLikeNotificationReadResult{ + Success: true, + Message: "All notifications marked as read successfully", + }, nil +} func (r *queryResolver) GetLikeNotifications(ctx context.Context, unreadOnly *bool, limit *int, offset *int) (*LikeNotificationsResponse, error) { userID, err := getUserIDFromContext(ctx) if err != nil { @@ -67,39 +101,3 @@ func (r *queryResolver) GetLikeNotifications(ctx context.Context, unreadOnly *bo UnreadCount: unreadCount, }, nil } - -// MarkLikeNotificationAsRead is the resolver for the markLikeNotificationAsRead field. -func (r *mutationResolver) MarkLikeNotificationAsRead(ctx context.Context, notificationID int) (*MarkLikeNotificationReadResult, error) { - userID, err := getUserIDFromContext(ctx) - if err != nil { - return nil, fmt.Errorf("authentication required: %w", err) - } - - err = r.Services.Like.MarkLikeNotificationAsRead(ctx, notificationID, userID) - if err != nil { - return nil, fmt.Errorf("failed to mark notification as read: %w", err) - } - - return &MarkLikeNotificationReadResult{ - Success: true, - Message: "Notification marked as read successfully", - }, nil -} - -// MarkAllLikeNotificationsAsRead is the resolver for the markAllLikeNotificationsAsRead field. -func (r *mutationResolver) MarkAllLikeNotificationsAsRead(ctx context.Context) (*MarkLikeNotificationReadResult, error) { - userID, err := getUserIDFromContext(ctx) - if err != nil { - return nil, fmt.Errorf("authentication required: %w", err) - } - - err = r.Services.Like.MarkAllLikeNotificationsAsRead(ctx, userID) - if err != nil { - return nil, fmt.Errorf("failed to mark all notifications as read: %w", err) - } - - return &MarkLikeNotificationReadResult{ - Success: true, - Message: "All notifications marked as read successfully", - }, nil -}