This commit is contained in:
greeneclipse committed 2026-10-16 13:48:51 +02:00
1 parent feebf7d3c1
commit 486502852e
41 files changed
+1311 -259

No files matched your search

+13
View File
@@ -6,6 +6,7 @@ import (
"strings"
"github.com/descrybe/descrybe-v2/apps/api/internal/catalog"
"github.com/descrybe/descrybe-v2/apps/api/internal/company"
"github.com/descrybe/descrybe-v2/apps/api/internal/feeds"
"github.com/go-chi/chi/v5"
"github.com/google/uuid"
@@ -68,6 +69,7 @@ func (s *Server) handleV1CreateFeed(w http.ResponseWriter, r *http.Request) {
FeedType string `json:"feed_type"`
SyncIntervalMinutes int `json:"sync_interval_minutes"`
SyncFrequency int `json:"sync_frequency"` // legacy hours
ContentLanguage string `json:"content_language"`
IsActive *bool `json:"is_active"`
}
if err := DecodeJSON(r, &body); err != nil {
@@ -87,6 +89,10 @@ func (s *Server) handleV1CreateFeed(w http.ResponseWriter, r *http.Request) {
return
}
if body.ContentLanguage != "" && !company.IsAllowedLanguage(body.ContentLanguage) {
v1Err(w, http.StatusBadRequest, "validation_error", "unsupported content language")
return
}
item, err := s.Feeds.Create(r.Context(), cid, feeds.CreateInput{
Name: name,
URL: url,
@@ -94,6 +100,7 @@ func (s *Server) handleV1CreateFeed(w http.ResponseWriter, r *http.Request) {
FeedType: body.FeedType,
SyncIntervalMinutes: body.SyncIntervalMinutes,
SyncFrequencyHours: body.SyncFrequency,
ContentLanguage: company.NormalizeLanguage(body.ContentLanguage),
})
if err != nil {
if msg, ok := feeds.ClientError(err); ok {
@@ -126,6 +133,11 @@ func (s *Server) createV1FeedFromMultipart(w http.ResponseWriter, r *http.Reques
feedType := strings.TrimSpace(r.FormValue("feed_type"))
interval, _ := strconv.Atoi(strings.TrimSpace(r.FormValue("sync_interval_minutes")))
freq, _ := strconv.Atoi(strings.TrimSpace(r.FormValue("sync_frequency")))
contentLanguage := strings.TrimSpace(r.FormValue("content_language"))
if contentLanguage != "" && !company.IsAllowedLanguage(contentLanguage) {
v1Err(w, http.StatusBadRequest, "validation_error", "unsupported content language")
return
}
file, header, fileErr := r.FormFile("file")
var options map[string]any
@@ -187,6 +199,7 @@ func (s *Server) createV1FeedFromMultipart(w http.ResponseWriter, r *http.Reques
FeedType: feedType,
SyncIntervalMinutes: interval,
SyncFrequencyHours: freq,
ContentLanguage: company.NormalizeLanguage(contentLanguage),
Options: options,
})
if err != nil {