add authentication for kontor-api-go

This commit is contained in:
Thomas Peetz
2025-12-01 06:53:03 +01:00
parent 741032ec02
commit 46bca919d7
5 changed files with 66 additions and 2 deletions
+5 -1
View File
@@ -6,8 +6,10 @@ import (
"fmt"
"kontor-api-go/pkg/schema"
"log"
"time"
"github.com/gofiber/fiber/v2"
"github.com/google/uuid"
"github.com/uptrace/bun"
)
@@ -51,7 +53,9 @@ func AddFile(c *fiber.Ctx) error {
if err != nil {
log.Fatal(err)
}
mediafile := &schema.MediaFile{WebLink: fmt.Sprintf("%s", link), Version: 1, ShouldDownload: true, Review: true}
id := uuid.NewString()
timestamp := time.Now()
mediafile := &schema.MediaFile{ID: id, CreatedAt: timestamp, UpdatedAt: timestamp, WebLink: fmt.Sprintf("%s", link), Version: 1, ShouldDownload: true, Review: true}
_, err = db.NewInsert().Model(mediafile).Exec(ctx)
if err != nil {
return err