This commit is contained in:
m
2026-07-13 11:47:48 +02:00
parent c3bb0dd6ab
commit 0aa3549561
6 changed files with 162 additions and 22 deletions
+12 -12
View File
@@ -3,22 +3,22 @@ package config
import "os"
type Config struct {
Port string
DatabaseURL string
OCREndpoint string
UploadDir string
HMACSecret string
ServerHost string
Port string
DatabaseURL string
OCREndpoint string
UploadDir string
HMACSecret string
ServerHost string
}
func Load() *Config {
return &Config{
Port: envOr("PORT", "8080"),
DatabaseURL: envOr("DATABASE_URL", "postgres://localhost:5432/vaultdrop?sslmode=disable"),
OCREndpoint: envOr("OCR_ENDPOINT", "http://localhost:9090"),
UploadDir: envOr("UPLOAD_DIR", "./uploads"),
HMACSecret: envOr("HMAC_SECRET", "thisismyrandomstring"),
ServerHost: envOr("SERVER_HOST", "http://192.168.1.17:8080"),
Port: envOr("PORT", "8080"),
DatabaseURL: envOr("DATABASE_URL", "postgres://localhost:5432/vaultdrop?sslmode=disable"),
OCREndpoint: envOr("OCR_ENDPOINT", "http://localhost:9090"),
UploadDir: envOr("UPLOAD_DIR", "./uploads"),
HMACSecret: envOr("HMAC_SECRET", "thisismyrandomstring"),
ServerHost: envOr("SERVER_HOST", "http://192.168.1.17:8080"),
}
}
+8 -2
View File
@@ -140,14 +140,20 @@ func (h *FileHandler) AddTags(c *gin.Context) {
id := c.Param("id")
var body struct {
Tags []string `json:"tags" binding:"required"`
Tags []string `json:"tags" binding:"required"`
TagType string `json:"tag_type"`
}
if err := c.ShouldBindJSON(&body); err != nil {
api.Error(c, http.StatusBadRequest, "INVALID_BODY", "Body must contain a 'tags' array")
return
}
if err := h.files.AddTags(id, body.Tags); err != nil {
tagType := body.TagType
if tagType == "" {
tagType = "none"
}
if err := h.files.AddTags(id, body.Tags, tagType); err != nil {
api.Error(c, http.StatusInternalServerError, "DB_ERROR", "Failed to add tags")
return
}
+2 -2
View File
@@ -122,14 +122,14 @@ func (s *FileService) UpdateOCRText(id, text string) error {
})
}
func (s *FileService) AddTags(fileID string, tagNames []string) error {
func (s *FileService) AddTags(fileID string, tagNames []string, tagType string) error {
for _, name := range tagNames {
tag, err := s.queries.GetTagByName(context.Background(), name)
if err == sql.ErrNoRows {
tag, err = s.queries.CreateTag(context.Background(), db.CreateTagParams{
ID: uuid.New().String(),
TagName: name,
TagType: "none",
TagType: tagType,
})
if err != nil {
return fmt.Errorf("create tag %q: %w", name, err)