Skip to content

Commit 88bd097

Browse files
committed
make image id nullable in handlers
1 parent b823327 commit 88bd097

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

internal/http/server/handlers/v1/stories.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ func StoriesIndex(ctr *container.Container) echo.HandlerFunc {
2222
}
2323

2424
type StoriesStoreRequest struct {
25-
Caption string `json:"caption" validate:"required"`
26-
AudioID uint64 `json:"audio_id" validate:"required"`
27-
ImageID uint64 `json:"image_id" validate:"required"`
25+
Caption string `json:"caption" validate:"required"`
26+
AudioID uint64 `json:"audio_id" validate:"required"`
27+
ImageID *uint64 `json:"image_id"`
2828
}
2929

3030
func StoriesStore(ctr *container.Container) echo.HandlerFunc {
@@ -68,8 +68,8 @@ func StoriesStore(ctr *container.Container) echo.HandlerFunc {
6868
}
6969

7070
var imageId *uint64
71-
if r.ImageID != 0 {
72-
image, err := ctr.FileService.FindByID(r.ImageID)
71+
if r.ImageID != nil {
72+
image, err := ctr.FileService.FindByID(*r.ImageID)
7373
if err != nil {
7474
return err
7575
}

0 commit comments

Comments
 (0)