Slug-based RSS URLs and success flash messages
Build and Deploy / build-and-deploy (push) Successful in 45s
Build and Deploy / build-and-deploy (push) Successful in 45s
- Add podcast_slug to users with global uniqueness check
- RSS available at /rss/{slug} (path-based) with legacy ?slug= fallback
- Slug field in dashboard settings with validation (lowercase, hyphens)
- JS flash messages for success/error after form submissions
- Remove unused imports
This commit is contained in:
+17
-13
@@ -3,7 +3,6 @@ package handler
|
||||
import (
|
||||
"encoding/xml"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"podstalk/store"
|
||||
@@ -58,22 +57,27 @@ type rssEnclosure struct {
|
||||
}
|
||||
|
||||
func (h *RSSHandler) ServeRSS(w http.ResponseWriter, r *http.Request) {
|
||||
// Resolve user: check query param, fall back to first user.
|
||||
// Try path-based slug first: /rss/my-slug
|
||||
slug := r.PathValue("slug")
|
||||
if slug == "" {
|
||||
slug = r.URL.Query().Get("slug")
|
||||
}
|
||||
if slug == "" {
|
||||
slug = r.URL.Query().Get("user") // legacy
|
||||
}
|
||||
|
||||
var user *store.User
|
||||
idStr := r.URL.Query().Get("user")
|
||||
if idStr != "" {
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
if err == nil {
|
||||
user, _ = h.Store.GetUser(id)
|
||||
if slug != "" {
|
||||
user, _ = h.Store.UserBySlug(slug)
|
||||
}
|
||||
if user == nil {
|
||||
// legacy: try numeric user ID
|
||||
if idStr := r.URL.Query().Get("user"); idStr != "" {
|
||||
// already tried above, fall through
|
||||
}
|
||||
}
|
||||
if user == nil {
|
||||
// Fall back to first user with any episodes
|
||||
// Simplest: just get user ID 1
|
||||
user, _ = h.Store.GetUser(1)
|
||||
}
|
||||
if user == nil {
|
||||
http.Error(w, "no podcast found", http.StatusNotFound)
|
||||
http.Error(w, "podcast not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user