app

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 189 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package app wires configuration, the database, background jobs, the HTTP API and every domain package into one runnable process.

Index

Constants

View Source
const PublicBaseURL = "https://reputecast.example.com"

PublicBaseURL is the default of the public document's baseUrl server variable: an SDK is given the instance's own URL.

View Source
const SourceGiftRedeem = "gift_redeem"

SourceGiftRedeem is the consent source of a redeemed gift.

Variables

This section is empty.

Functions

func ApprovalsTickAt

func ApprovalsTickAt(a *App, now time.Time) error

ApprovalsTickAt runs Review & send's minute job as if it were now: tests move the clock to a scheduled send's recheck, or past a held send's expiry.

func CampaignChangeHook

func CampaignChangeHook(a *App) campaigns.ChangeHook

CampaignChangeHook re-checks a campaign's open approval after the composer saved it (the composer's campaigns.Service.AfterChange).

func HeldSendCheck

func HeldSendCheck(a *App) func(ctx context.Context, workspaceID, campaignID uuid.UUID) error

HeldSendCheck is the send-time check the minute job runs for scheduled and held sends: it holds a send that turns Blocked or lost its approval (and tells people), and returns an error wrapping sending.ErrNotReady.

func NewHumaConfig

func NewHumaConfig() huma.Config

NewHumaConfig returns the OpenAPI configuration shared by the server and the `reputecast openapi` command.

func PublicSpec

func PublicSpec(spec *huma.OpenAPI) (*huma.OpenAPI, error)

PublicSpec returns the document the client SDKs are generated from (sdk/openapi): the operations an API key may call, except the ones only the integration apps call (x-integration), with only the schemas they reference. Its version is the binary's, its server is the instance URL (paths keep their /api/v1 prefix), and every operation authenticates with a bearer key. spec itself is left as it was: the web app's document is generated from it.

func ReadinessQueue

func ReadinessQueue(ctx context.Context, a *App) (int, error)

ReadinessQueue works the Send Readiness runs waiting in the job queue, in this process: tests (whose app runs no workers) call it after asking for a run. It returns how many it worked.

func RegisterOperations

func RegisterOperations(h huma.API)

RegisterOperations registers every operation on h without a database, for generating the OpenAPI document. Handlers are never called.

func SecretBox

func SecretBox(cfg *config.Config, log *slog.Logger) (*secrets.Box, error)

SecretBox loads the encryption key (from config or the key file) and returns the box that seals secrets at rest.

func SendRecheck

func SendRecheck(a *App) func(ctx context.Context, campaignID uuid.UUID) (approvals.SendRecheck, error)

SendRecheck is the recheck the sending engine runs as a send starts (its sending.Readiness, via readinessRecheck): Send Readiness again, and the approval must still cover the campaign. It records nothing; the engine holds the send when the verdict is Blocked.

Types

type App

type App struct {
	Cfg     *config.Config
	Log     *slog.Logger
	Pool    *pgxpool.Pool
	Q       *store.Queries
	Secrets *secrets.Box
	Audit   *audit.Logger
	Jobs    *jobs.Client
	JobReg  *jobs.Registry
	Auth    *api.Authenticator
	Metrics *prometheus.Registry
	// Mail sends system mail through the System-stream provider.
	Mail mailer.Sender
	// Sending starts, pauses, resumes and cancels campaign sends; set by the
	// sending domain's start hook.
	Sending sending.Starter
	// Links signs open, click, unsubscribe and preference tokens in emails.
	Links *linktoken.Signer
	// Counts keeps the slow audience counts that read every contact for a
	// minute (review 2026-11 OP-12); audited contact changes drop a
	// workspace's.
	Counts *countcache.Cache
	// Now is the clock of the services that read it (texting); nil is the
	// wall clock. Tests that seed the sample at a fixed moment set it.
	Now func() time.Time
	// URLs builds public links (tracking, unsubscribe, preferences, archive,
	// shared reports, provider webhooks) on the instance's public URL.
	URLs publicurl.Builder
	// PublicURL is that URL: the saved instance setting, else http.public_url
	// (see wire_publicurl.go).
	PublicURL *publicurl.Source
	// GeoIP places readers' opens and clicks by country and city for the
	// campaign report (geoip.database), loaded in the background at start;
	// nil when it isn't configured. Its methods are nil-safe.
	GeoIP *geoip.DB
	// Blobs keeps the files stored outside the database (products' files,
	// lead magnets, uploads in progress, audience exports): the files
	// folder or an S3-compatible bucket (storage.backend).
	Blobs blobstore.Store
	// contains filtered or unexported fields
}

App holds the shared dependencies every domain uses.

func New

func New(ctx context.Context, cfg *config.Config, log *slog.Logger) (*App, error)

New connects to the database and builds every dependency. It does not start listeners or workers; see Run.

func (*App) Assistant

func (a *App) Assistant() *assistant.Service

Assistant is the AI assistant's threads (B3), on the AI service's models, budget and projections.

func (*App) Audience

func (a *App) Audience() *audience.Service

Audience is the audience service (tests and tools reach it here).

func (*App) Close

func (a *App) Close()

Close releases what the domains keep per App, then the database pool.

func (*App) Commerce

func (a *App) Commerce() *commerce.Service

Commerce is the stores' domain (tests set its clock and its stores).

func (*App) CommunityRuntime

func (a *App) CommunityRuntime() *remote.Runtime

CommunityRuntime is the App's community adapter runtime (tests that change the configuration stop its sync loop first).

func (*App) Countdowns

func (a *App) Countdowns() *countdown.Service

Countdowns is the countdown domain (tests set its clock).

func (*App) Coupons

func (a *App) Coupons() *coupons.Service

Coupons is the discount codes domain (tests set its clock).

func (*App) Digests

func (a *App) Digests() *digests.Service

Digests returns the App's digests service (tests drive its jobs).

func (*App) Earn

func (a *App) Earn() *earn.Service

Earn is the Earn domain (tests set its clock and its Stripe).

func (*App) Forms

func (a *App) Forms() *forms.Service

Forms is the signup forms service (tests swap its clock or GeoIP).

func (*App) Gifts

func (a *App) Gifts() *gifts.Service

Gifts is the gifts domain (tests set its clock).

func (*App) Handler

func (a *App) Handler() http.Handler

Handler builds the full HTTP handler for the configured roles.

func (*App) Holdout

func (a *App) Holdout() *holdout.Service

Holdout is the holdout domain (tests set its clock and measure).

func (*App) Inbound

func (a *App) Inbound() *inbound.Service

Inbound is the receiving service (tests drive its jobs).

func (*App) InvalidatePolicy

func (a *App) InvalidatePolicy()

InvalidatePolicy drops the cached authentication policy after a change.

func (*App) LeadAds

func (a *App) LeadAds() *leads.Service

LeadAds is the lead ads domain (tests set its clock).

func (*App) LeadAdsFake

func (a *App) LeadAdsFake() *metatest.Fake

LeadAdsFake is the in-process Graph API the demo's connection (and tests) answer from: nothing reaches Meta.

func (*App) MCPClient

func (a *App) MCPClient() *mcpclient.Service

MCPClient is the assistant's remote MCP servers (B5). Servers on private addresses follow providers.allow_private_networks; OAuth sends people back to the instance's public URL.

func (*App) Offers

func (a *App) Offers() *offers.Service

Offers is the offers domain (tests set its clock).

func (*App) Pages

func (a *App) Pages() *pages.Service

Pages is the pages domain (tests set its clock).

func (*App) PinPublicURL

func (a *App) PinPublicURL(ctx context.Context) error

PinPublicURL makes the address the server locks (http.public_url_locked) the saved public URL when another one is saved, and moves provider webhooks to it when an admin had saved another address. So turning the lock on, or the operator changing the locked address, takes effect at the next start without anyone saving it in Instance admin. One process wins the update, so webhooks move once; the change is audited as the server configuration's.

func (*App) Products

func (a *App) Products() *products.Service

Products is the products domain (tests set its clock).

func (*App) ProxyDetector

func (a *App) ProxyDetector() *proxycheck.Detector

ProxyDetector returns the App's untrusted proxy detector (tests flush it).

func (*App) Push

func (a *App) Push() *push.Service

Push is the web push domain.

func (*App) PushFake

func (a *App) PushFake() *webpushtest.Service

PushFake is the in-process push service the demo's subscriptions (and tests) are sent to: nothing reaches FCM, Mozilla, Apple or Windows.

func (*App) Revenue

func (a *App) Revenue() *revenue.Service

Revenue is Earn's revenue and attribution (tests set its clock).

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run serves HTTP (web/ingest roles) and runs workers (worker role) until ctx ends.

func (*App) RunSMTPRelay

func (a *App) RunSMTPRelay(ctx context.Context) error

RunSMTPRelay runs the SMTP relay's listeners until ctx ends, in processes with the web role (the relay is an API surface, like the HTTP API). It returns once the listeners stopped gracefully.

func (*App) SMTPRelay

func (a *App) SMTPRelay() *smtprelay.Relay

SMTPRelay is the App's SMTP relay (tests drive it).

func (*App) Scoring

func (a *App) Scoring() *scoring.Service

Scoring is the scoring domain (tests set its clock).

func (*App) SendingEngine

func (a *App) SendingEngine() *engine.Engine

SendingEngine returns the App's sending engine (the demo command drives it).

func (*App) Sponsors

func (a *App) Sponsors() *sponsors.Service

Sponsors is the sponsorships domain (tests set its clock).

func (*App) Tracker

func (a *App) Tracker() *tracker.Service

Tracker is the site tracker (tests set its clock and flush its writer).

func (*App) Transactional

func (a *App) Transactional() *transactional.Service

Transactional is the transactional domain (tests set its clock).

func (*App) TransactionalOutbox

func (a *App) TransactionalOutbox() *engine.TransactionalOutbox

TransactionalOutbox is the sending engine's transactional outbox (tests drive it with Step).

func (*App) Website

func (a *App) Website() *website.Service

Website is the website domain (tests set its clock).

func (*App) WhatsApp

func (a *App) WhatsApp() *whatsapp.Service

WhatsApp is the WhatsApp domain.

func (*App) WhatsAppFake

func (a *App) WhatsAppFake() *metatest.Fake

WhatsAppFake is the in-process Graph API the demo's account (and tests) answer from: nothing reaches Meta.

Source Files

Jump to

Keyboard shortcuts

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