notification

package
v0.90.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 19 Imported by: 0

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

View Source
const MaxPublish = 100

MaxPublish bounds one publish batch.

Variables

View Source
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

func Migrate added in v0.90.0

func Migrate(ctx context.Context, pool *pgxpool.Pool, schema string) error

Migrate creates and upgrades a notification-only schema. Replicas serialize schema creation as well as the shared helper's versioned table migration.

Types

type Config added in v0.90.0

type Config struct {
	Schema        string               `json:"schema" yaml:"schema"`
	Namespace     string               `json:"namespace" yaml:"namespace"`
	SharedOrigins []notify.OriginScope `json:"shared_origins,omitempty" yaml:"shared_origins,omitempty"`
}

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
	Shared         *Config
	// 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

type Publication struct {
	Notifications []notify.Input `json:"notifications"`
}

Publication is a batch of notices a host service publishes.

type Published added in v0.82.0

type Published struct {
	Items []notify.Item `json:"items"`
}

Published is each notice of a Publication as stored, in order, without those dropped for an erased recipient.

type Store

type Store struct {
	*postgres.Store
	// contains filtered or unexported fields
}

Store mounts a shared notification store as one ContentKit tenant's inbox. Embedded methods accept trusted host inputs; HTTP derives the user identity.

func New

func New(opts Options) (*Store, error)

New constructs the adapter over tables contentkit.New installs.

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

func (s *Store) AppID() string

AppID is the fixed app presentation boundary, empty only on legacy runtimes.

func (*Store) BindMerchant added in v0.90.0

func (s *Store) BindMerchant(ctx context.Context, tenantID string, origin notify.OriginScope) error

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

func (s *Store) EraseAppRecipient(ctx context.Context, r notify.Recipient) error

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) Get added in v0.90.0

func (s *Store) Get(ctx context.Context, r notify.Recipient, id string) (notify.Item, error)

func (*Store) Handler

func (s *Store) Handler(a auth.Authenticator) (http.Handler, error)

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) List added in v0.90.0

func (*Store) Namespace added in v0.90.0

func (s *Store) Namespace() string

Namespace is the stable shared account namespace, or the legacy tenant.

func (*Store) Publish added in v0.90.0

func (s *Store) Publish(ctx context.Context, in notify.Input) (notify.Item, error)

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

func (s *Store) PublishBatch(ctx context.Context, in []notify.Input) ([]notify.Item, error)

PublishBatch stores a batch in one transaction (see the publish route).

func (*Store) PublishTx added in v0.90.0

func (s *Store) PublishTx(ctx context.Context, tx pgx.Tx, in notify.Input) (notify.Item, error)

func (*Store) SetDismissed added in v0.90.0

func (s *Store) SetDismissed(ctx context.Context, r notify.Recipient, id string, dismissed bool) (notify.Item, error)

func (*Store) SetRead added in v0.90.0

func (s *Store) SetRead(ctx context.Context, r notify.Recipient, id string, read bool) (notify.Item, error)

Directories

Path Synopsis
Package openrails consumes independently acknowledged OpenRails notification events.
Package openrails consumes independently acknowledged OpenRails notification events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL