On first boot create the single household_settings row with the zone from MEALQUEST_DEFAULT_TZ and the seed times and days (dinner 17:30, reminder 16:30, rotation check 09:00, plan draft Fri 09:00, suggestions Sun 08:00, chat autosend Sat 08:00). Boot fails if the row is missing and the zone is unset; an existing row is never overwritten. Config validates the zone whenever it is set. Add household.SettingsService with Get, a validating Update (IANA zone, zero-padded 24-hour HH:MM, day of week 0-6) that records updated_by, and in-process Subscribe for the scheduler. Serve it as GET and PATCH /api/v1/settings/household; invalid input is a 400 in the standard error body. Migration 0002 adds household_settings.updated_by, and internal/actor carries the member name in the request context. Link time/tzdata from internal/household so zones load in the minimal image, which has no system zone database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
534 B
Go
19 lines
534 B
Go
// Package actor carries the signed-in member's name in a request context, so
|
|
// changes can record who made them (the updated_by columns).
|
|
package actor
|
|
|
|
import "context"
|
|
|
|
type key struct{}
|
|
|
|
// With returns a copy of ctx naming the member making the request.
|
|
func With(ctx context.Context, name string) context.Context {
|
|
return context.WithValue(ctx, key{}, name)
|
|
}
|
|
|
|
// From returns the member named in ctx, or "" when no member is known.
|
|
func From(ctx context.Context) string {
|
|
name, _ := ctx.Value(key{}).(string)
|
|
return name
|
|
}
|