Migrate ingest and API paths to string IDs
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user