From be27f4ae8ce7434eaec0dc26e2ba7bb987dda8d1 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 18 Sep 2025 00:10:15 +0300 Subject: [PATCH] =?UTF-8?q?v0.0.33=20=D0=A3=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20=D0=BB=D0=B0=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../http/graph/like_notification_resolvers.go | 72 +++++++++---------- 1 file changed, 35 insertions(+), 37 deletions(-) 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 -}