Alex Dunmow 945ca508e0 Judge site data table reads by the fields the spec declares (ADR 0007 amendment)
With data_tables in acceptance.json, a public route over a site data
table fails check 33 only when the table read holds a personal field by
the spec or the classifier. The table is resolved from a literal
GetTableByKey key; an unresolved read falls back to any declared table
being personal. Without data_tables every read stays personal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:48:11 +08:00

42 lines
1014 B
Go

package main
import (
"encoding/json"
"net/http"
"git.dev.alexdunmow.com/block/pluginsdk/plugin"
"git.dev.alexdunmow.com/block/pluginsdk/route"
)
const pluginName = "upcoming-events-5d1e22"
// Registration is the plugin entry registration.
var Registration = plugin.PluginRegistration{
Name: pluginName,
Version: "1.0.0",
HTTPHandler: newHTTPHandler,
}
var current plugin.CoreServices
func newHTTPHandler(deps plugin.CoreServices) http.Handler {
current = deps
r := route.New(pluginName)
r.Handle(http.MethodGet, "/events.ics", route.Public, handleList)
return r
}
func handleList(w http.ResponseWriter, r *http.Request) {
table, err := current.DataTables.GetTableByKey(r.Context(), "events")
if err != nil {
http.Error(w, "not found", http.StatusNotFound)
return
}
rows, err := current.DataTables.ListRows(r.Context(), table.ID, 100, 0)
if err != nil {
http.Error(w, "could not load rows", http.StatusInternalServerError)
return
}
_ = json.NewEncoder(w).Encode(rows)
}