Migrate ingest and API paths to string IDs

This commit is contained in:
2026-02-14 20:10:23 +03:00
parent 6df92b7a69
commit 3ffdf9b0e1
42 changed files with 1958 additions and 437 deletions

View File

@@ -8,7 +8,7 @@ import (
"reanimator/internal/repository/timeline"
)
func writeTimelineResponse(w http.ResponseWriter, r *http.Request, repo *timeline.EventRepository, subjectType string, subjectID int64) {
func writeTimelineResponse(w http.ResponseWriter, r *http.Request, repo *timeline.EventRepository, subjectType string, subjectID string) {
limit := 50
if raw := r.URL.Query().Get("limit"); raw != "" {
if parsed, err := strconv.Atoi(raw); err == nil {
@@ -47,18 +47,17 @@ func writeTimelineResponse(w http.ResponseWriter, r *http.Request, repo *timelin
})
}
func parseTimelineID(path, prefix string) int64 {
func parseTimelineID(path, prefix string) string {
if !strings.HasPrefix(path, prefix) || !strings.HasSuffix(path, "/timeline") {
return 0
return ""
}
trimmed := strings.TrimPrefix(path, prefix)
trimmed = strings.TrimSuffix(trimmed, "/timeline")
if trimmed == "" || strings.Contains(trimmed, "/") {
return 0
return ""
}
id, err := strconv.ParseInt(trimmed, 10, 64)
if err != nil || id <= 0 {
return 0
if !entityIDPattern.MatchString(trimmed) {
return ""
}
return id
return trimmed
}