Documentation
¶
Overview ¶
Package notification adapts the shared helpers/notify inbox to ContentKit's authenticated user API. Persistence and lifecycle belong to helpers/notify; hosts own rendering and application-specific actions.
Index ¶
- Constants
- Variables
- func Migrate(ctx context.Context, pool *pgxpool.Pool, schema string) error
- type Config
- type Options
- type Publication
- type Published
- type Store
- func (s *Store) AllowOrigin(origin notify.OriginScope) error
- func (s *Store) AppID() string
- func (s *Store) BindMerchant(ctx context.Context, tenantID string, origin notify.OriginScope) error
- func (s *Store) EraseAppRecipient(ctx context.Context, r notify.Recipient) error
- func (s *Store) ErasedRecipients(ctx context.Context, after string, limit int) ([]notify.Recipient, error)
- func (s *Store) Get(ctx context.Context, r notify.Recipient, id string) (notify.Item, error)
- func (s *Store) Handler(a auth.Authenticator) (http.Handler, error)
- func (s *Store) List(ctx context.Context, r notify.Recipient, o notify.ListOptions) (notify.Page, error)
- func (s *Store) Namespace() string
- func (s *Store) Publish(ctx context.Context, in notify.Input) (notify.Item, error)
- func (s *Store) PublishBatch(ctx context.Context, in []notify.Input) ([]notify.Item, error)
- func (s *Store) PublishTx(ctx context.Context, tx pgx.Tx, in notify.Input) (notify.Item, error)
- func (s *Store) SetDismissed(ctx context.Context, r notify.Recipient, id string, dismissed bool) (notify.Item, error)
- func (s *Store) SetRead(ctx context.Context, r notify.Recipient, id string, read bool) (notify.Item, error)
Constants ¶
const MaxPublish = 100
MaxPublish bounds one publish batch.
Variables ¶
var ErrMerchantBinding = errors.New("notification: merchant is bound to another tenant or source")
ErrMerchantBinding rejects a source that is not the tenant's verified billing association. It never reassigns a tenant or merchant during normal startup.
Functions ¶
Types ¶
type Config ¶ added in v0.90.0
type Config struct {
Schema string `json:"schema" yaml:"schema"`
Namespace string `json:"namespace" yaml:"namespace"`
}
Config shares an account inbox without sharing a site's content catalog. Sites must share verified recipient IDs and the same Postgres database.
type Options ¶
type Options struct {
Pool *pgxpool.Pool
Schema, Tenant string
Logger *slog.Logger
// AppID comes from the engine immutable Scope, never from an HTTP selector.
AppID string
}
Options selects the pool, ContentKit's schema and its tenant.
type Publication ¶ added in v0.82.0
Publication is a batch of notices a host service publishes.
type Published ¶ added in v0.82.0
Published is each notice of a Publication as stored, in order, without those dropped for an erased recipient.
type Store ¶
Store mounts a shared notification store as one ContentKit tenant's inbox. Embedded methods accept trusted host inputs; HTTP derives the user identity.
func (*Store) AllowOrigin ¶ added in v0.90.0
func (s *Store) AllowOrigin(origin notify.OriginScope) error
AllowOrigin adds one trusted producer namespace to a shared site's view. Called by integrations during startup; it grants no recipient authority.
func (*Store) AppID ¶ added in v0.90.0
AppID is the fixed app presentation boundary, empty only on legacy runtimes.
func (*Store) BindMerchant ¶ added in v0.90.0
BindMerchant pins one verified producer/merchant pair to an already registered tenant account store. Matching concurrent app startups are idempotent; neither another tenant's merchant nor another merchant for this tenant can be attached.
func (*Store) EraseAppRecipient ¶ added in v0.90.0
EraseAppRecipient fences only this configured app's notices, never the tenant inbox or another app's receipts. It also identifies the app's legacy native origin without including shared billing origins.
func (*Store) ErasedRecipients ¶ added in v0.90.0
func (s *Store) ErasedRecipients(ctx context.Context, after string, limit int) ([]notify.Recipient, error)
ErasedRecipients is the canonical account/app erasure list for replay after restoring only this app's data. It never returns a sibling's app-only fences.
func (*Store) Handler ¶
Handler serves the authenticated person's inbox and read state, and the host service's publish route. People select no recipient and write no notices.
func (*Store) Namespace ¶ added in v0.90.0
Namespace is the stable shared account namespace, or the legacy tenant.
func (*Store) Publish ¶ added in v0.90.0
Publish defaults native/host authored notices to this app. Tenant-wide publication is reserved for trusted in-process integrations; the HTTP route does not accept that authority from an app client.
func (*Store) PublishBatch ¶ added in v0.82.0
PublishBatch stores a batch in one transaction (see the publish route).