Files
sm-feedback-plugin/routes.go
Jakub Zych af5d77c997 feat: G15Office job, widget settings and submissions admin, embed.js and the settings importer
- SyncG15Office files each submission as a G15Office task with its screenshot through a fetchguard client limited to the configured host; a River job with 3 attempts, PHP's messages on failure, nothing sent when unconfigured
- the replay of PHP's recorded G15Office exchange (classes/testdata) asserts the task JSON, headers and the screenshot part
- settings screen (cabana field types only), read-only submissions list, manage_settings permission and navigation
- embed.js served byte for byte at /plugins/golem15/feedback/assets/js/embed.js
- feedback:import-settings copies the WinterCMS settings row once
2026-10-04 00:22:08 +02:00

27 lines
1.1 KiB
Go

package feedback
import (
"git.golem15.com/golem15/sm-feedback-plugin/controllers/api"
"git.golem15.com/golem15/summercms/modules/pact"
"git.golem15.com/golem15/summercms/modules/surf"
)
// Routes mounts the widget API. The public group has no auth: the widget
// key in the path and the Origin allow-list are its gate, backed by the
// per-IP buckets. CORS preflights (OPTIONS) on _feedback/api/* are answered
// by surf's path-scoped CORS layer, which the application's http.cors.paths
// must list, so no OPTIONS route is registered. A second group on the same
// prefix carries the per-user preference behind golem15.user's jwt.auth.
func (p *Plugin) Routes(r pact.Router) error {
r.Group("/_feedback/api/v1", nil, func(g pact.Router) {
g.Get("/{key}/config", api.Config(p.app), "throttle:"+BucketConfig)
g.Post("/{key}/submit", api.Submit(p.app), "throttle:"+BucketSubmit)
})
r.Group("/_feedback/api/v1", surf.Use("jwt.auth"), func(g pact.Router) {
g.Put("/me/hidden", api.MeHidden(p.app))
})
// The widget script, at the path of the WinterCMS plugin's file.
r.Get(EmbedJSPath, EmbedJS())
return nil
}