v0.0.33 Уведомления о лайках
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
admin 2025-09-18 00:10:15 +03:00
parent d7b74cd403
commit be27f4ae8c

View File

@ -5,7 +5,41 @@ import (
"fmt" "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) { func (r *queryResolver) GetLikeNotifications(ctx context.Context, unreadOnly *bool, limit *int, offset *int) (*LikeNotificationsResponse, error) {
userID, err := getUserIDFromContext(ctx) userID, err := getUserIDFromContext(ctx)
if err != nil { if err != nil {
@ -67,39 +101,3 @@ func (r *queryResolver) GetLikeNotifications(ctx context.Context, unreadOnly *bo
UnreadCount: unreadCount, UnreadCount: unreadCount,
}, nil }, 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
}