fix: in "CreateList", the authenticated userid is now added in the service layer, rather than the handler layer

This commit is contained in:
2026-08-20 15:32:54 +02:00
parent a5d649dbf5
commit abb3d154f8
2 changed files with 6 additions and 7 deletions
+1 -7
View File
@@ -3,7 +3,6 @@ package handler
import (
"log/slog"
"net/http"
"slices"
"github.com/robindittmar/dttmr-api/internal/api/request"
"github.com/robindittmar/dttmr-api/internal/api/response"
@@ -47,12 +46,7 @@ func (h *ListHandler) CreateList(w http.ResponseWriter, r *http.Request) {
return
}
// TODO: should this be in ListService?
if !slices.Contains(payload.UserIDs, authContext.UserID) {
payload.UserIDs = append(payload.UserIDs, authContext.UserID)
}
list, err := h.ListService.Create(ctx, payload.Name, payload.UserIDs)
list, err := h.ListService.Create(ctx, authContext.UserID, payload.Name, payload.UserIDs)
if err != nil {
slog.ErrorContext(ctx, "failed to create list", slog.Any("error", err))
response.Error(ctx, w, http.StatusInternalServerError, "failed to create list")