feat(feeds): expose retained operation history and read-only rechecks
Build and publish container images / images (push) Successful in 11m14s

This commit is contained in:
Anya Tokugawa committed 2026-11-08 06:35:53 +09:00
1 parent e4c184d71c
commit 1057be6d2b
12 files changed
+547 -10

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
package server
import (
"encoding/json"
"net/http"
"strconv"
"time"
"github.com/google/uuid"
"pageswiki/internal/store"
)
func writeFeedHistoryJSON(w http.ResponseWriter, value any) {
w.Header().Set("Cache-Control", "private, no-store")
w.Header().Set("Content-Type", "application/json; charset=utf-8")
_ = json.NewEncoder(w).Encode(value)
}
func (s *Server) handleFeedHistory(w http.ResponseWriter, r *http.Request, domain, actor, key string) bool {
if r.Method != "GET" || (key != "actions" && key != "action/export") {
return false
}
if key == "action/export" {
a, e := s.store.FeedActionRecord(r.Context(), domain, actor, r.URL.Query().Get("request_id"))
if e != nil {
taskError(w, e)
return true
}
id, _ := uuid.Parse(a.RequestID)
w.Header().Set("Content-Disposition", `attachment; filename="pageswiki-feed-action-`+id.String()+`.json"`)
w.Header().Set("X-Content-Type-Options", "nosniff")
writeFeedHistoryJSON(w, map[string]any{"format": "pageswiki.feed-action", "version": 1, "exported_ms": time.Now().UnixMilli(), "domain_uuid": domain, "owner_uuid": actor, "action": a})
return true
}
q := r.URL.Query()
query := store.FeedActionQuery{Source: q.Get("source"), Status: q.Get("status"), Before: -1, Key: q.Get("key")}
if q.Has("before") {
var e error
query.Before, e = strconv.ParseInt(q.Get("before"), 10, 64)
if e != nil || query.Before < 0 {
taskError(w, store.ErrTaskInvalid)
return true
}
}
items, e := s.store.FeedActionHistory(r.Context(), domain, actor, query)
if e != nil {
taskError(w, e)
return true
}
more := len(items) > 50
if more {
items = items[:50]
}
writeFeedHistoryJSON(w, map[string]any{"actions": items, "more": more})
return true
}