Add lifecycle_status = 'published' to the public-catalog queries (plans and add-ons listings) and reject checkout before any Stripe call unless the product behind the price clears the shared member gate (published + active + public). The currently-enrolled ladder rung stays renderable even if its product is later drafted or retired, fetched directly so members keep seeing what they are on. Introduce a single evaluateMemberGate definition shared by the catalog paths and the operator readiness panel so the surfaces cannot disagree about what is publishable for members.
52 lines
1.8 KiB
Go
52 lines
1.8 KiB
Go
// Package maintenance holds Temporal workflows and activities for
|
|
// cross-cutting database maintenance — currently the recurring ensure pass
|
|
// that keeps core.webhook_events' monthly RANGE partitions provisioned
|
|
// ahead of need (design.md D3, webhook-partition-maintenance spec).
|
|
package maintenance
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"log/slog"
|
|
"time"
|
|
|
|
"git.coopcloud.tech/wiki-cafe/member-console/internal/db"
|
|
)
|
|
|
|
// Activities holds dependencies for webhook_events partition-maintenance
|
|
// activities.
|
|
type Activities struct {
|
|
database *sql.DB
|
|
logger *slog.Logger
|
|
}
|
|
|
|
// NewActivities constructs an Activities ready for registration.
|
|
func NewActivities(database *sql.DB, logger *slog.Logger) *Activities {
|
|
if logger == nil {
|
|
logger = slog.Default()
|
|
}
|
|
return &Activities{database: database, logger: logger}
|
|
}
|
|
|
|
// EnsureWebhookPartitionsOutput reports one ensure pass.
|
|
type EnsureWebhookPartitionsOutput struct {
|
|
MonthsAhead int
|
|
}
|
|
|
|
// EnsureWebhookPartitionsActivity creates any missing monthly RANGE
|
|
// partitions of core.webhook_events for the current month through
|
|
// db.DefaultWebhookPartitionMonthsAhead months ahead. It is idempotent
|
|
// (CREATE TABLE IF NOT EXISTS), so re-running it — on the recurring
|
|
// schedule this backs, or racing the console's own boot pass — changes
|
|
// nothing it should not.
|
|
func (a *Activities) EnsureWebhookPartitionsActivity(ctx context.Context) (EnsureWebhookPartitionsOutput, error) {
|
|
monthsAhead := db.DefaultWebhookPartitionMonthsAhead
|
|
if err := db.EnsureWebhookEventPartitions(ctx, a.database, time.Now(), monthsAhead); err != nil {
|
|
if a.logger != nil {
|
|
a.logger.Warn("webhook_events partition ensure failed", slog.Any("error", err))
|
|
}
|
|
return EnsureWebhookPartitionsOutput{}, err
|
|
}
|
|
return EnsureWebhookPartitionsOutput{MonthsAhead: monthsAhead}, nil
|
|
}
|