integrations

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 51 Imported by: 0

Documentation

Overview

Package integrations is the integrations hub (design expansion, phase 2, M16): the catalog of Settings › Integrations, connections to Zapier, Make, n8n and WordPress sites with one key each, the REST hooks those apps subscribe with, the actions they call, the 7-day call log, managed webhooks, health, and the WordPress site API.

An integration key is an API key with integration_id set. It works only for the operations of the triggers and actions turned on, even where its permissions would allow more: internal/api asks Key for that list on every call (see api.Integrations) and logs the call through Record.

Index

Constants

View Source
const (
	CodeUnsubscribed = "unsubscribed"
	CodeSuppressed   = "suppressed"
)

Consent conflict codes: an action never adds someone back to a list they left, and never adds a suppressed address.

View Source
const (
	KindZapier    = "zapier"
	KindMake      = "make"
	KindN8n       = "n8n"
	KindWordPress = "wordpress"
)

Kinds of connections.

View Source
const (
	OpMe          = "get-integration"
	OpSubscribe   = "subscribe-integration-hook"
	OpUnsubscribe = "unsubscribe-integration-hook"
	OpGetHook     = "get-integration-hook"
	OpSample      = "get-integration-trigger-sample"
	OpForms       = "list-integration-forms"
	OpLists       = "list-integration-lists"
	OpFields      = "list-integration-fields"
	OpUpsert      = "upsert-contact"
	OpAddToList   = "add-contact-to-list"
	OpTag         = "tag-contact"
	OpEvent       = "send-automation-event" // internal/automations
	OpTemplates   = "list-integration-templates"
	OpSendMessage = "send-transactional-message" // internal/transactional (M15)
	OpWPReport    = "report-wordpress-site"
	OpWPForms     = "list-wordpress-forms"
	OpWPDraft     = "create-wordpress-draft"
)

Operation IDs the integrations call. Those of other packages are listed by name; an unknown ID in a list is harmless.

View Source
const (
	ItemTrigger = "trigger"
	ItemAction  = "action"
)

Item kinds.

View Source
const (
	ReasonKeyRevoked        = "key_revoked"
	ReasonKeyExpired        = "key_expired"
	ReasonOwnerLeft         = "owner_left"
	ReasonKeyExpiring       = "key_expiring"
	ReasonDeliveriesFailing = "deliveries_failing"
	ReasonCallsFailing      = "calls_failing"
	ReasonSiteSilent        = "site_silent"
)

Reasons an integration needs attention (brief 3.1).

View Source
const (
	StatusNotConnected = "not_connected"
	StatusWaiting      = "waiting"
	StatusConnected    = "connected"
	StatusAttention    = "attention"
)

Statuses of a catalog entry.

View Source
const CallRetention = 7 * 24 * time.Hour

CallRetention is how long the call log keeps calls.

View Source
const DefaultCheckTimeout = 10 * time.Second

DefaultCheckTimeout bounds "Check now".

View Source
const KnownPluginVersion = "1.4.0"

KnownPluginVersion is the WordPress plugin release this version of ReputeCast knows. With the update check off, "Update available" compares with it. 1.4.0 adds WooCommerce: the checkout's consent, the click token on orders and abandoned checkouts (internal/commerce).

View Source
const Masked = "••••••"

Masked replaces a sensitive value in a stored body.

View Source
const PluginInfoURL = "https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request%5Bslug%5D=reputecast"

PluginInfoURL is the WordPress plugin directory's answer about the plugin.

View Source
const RotationGrace = 24 * time.Hour

RotationGrace is how long a rotated integration key keeps working.

View Source
const SiteSilentAfter = 24 * time.Hour

SiteSilentAfter is when a site that hasn't reported in needs attention.

View Source
const WorkflowRetention = 30 * 24 * time.Hour

WorkflowRetention is how long a workflow stays listed after its last call.

Variables

View Source
var Groups = []Group{
	{Key: "automation", Entries: []string{KindZapier, KindMake, KindN8n}},
	{Key: "websites", Entries: []string{KindWordPress}},
	{Key: "deliverability", Entries: []string{"hostrepute"}},
	{Key: "developer", Entries: []string{"api", "webhooks", "mcp"}},
	{Key: "ai"},
	{Key: "verification"},
	{Key: "payments"},
	{Key: "commerce"},
}

Groups of the catalog (brief 3.1). Phase 2 fills the first four.

Functions

func ContactEventData

func ContactEventData(c store.IntegrationEventContactsRow) map[string]any

ContactEventData is a contact as contact events carry it.

func DefaultItems

func DefaultItems(kind string) []string

DefaultItems are what starts on when connecting: everything except items that need a ⚑ permission.

func Erasure

func Erasure() erasure.Source

Erasure is the bodies of integration calls about the contact (kept 7 days) and contact events not yet sent to endpoints; contact.erased is queued after this runs (review 2026-11 DP-1).

func IsPlatform

func IsPlatform(kind string) bool

IsPlatform reports whether kind is an automation platform.

func Name

func Name(kind string) string

Name is how people call a kind.

func Needs

func Needs(it Item) []authz.Permission

Needs returns every permission an item needs from the person who turns it on: its own, plus webhooks:manage for triggers.

func Operations

func Operations(kind string, items []string) map[string]bool

Operations returns the operation IDs a key with these items may call.

func Permissions

func Permissions(kind string, items []string) []authz.Permission

Permissions returns the permissions a key with these items holds, in the order of the catalog: the items' permissions, then webhooks:manage for the endpoints it creates when a trigger is on.

func Register

func Register(h huma.API, s *Service)

Register adds the integrations hub's operations: the people-facing hub (integrations:view to read, integrations:manage to change, people only) and the API the apps and the WordPress plugin call.

func RegisterJobs

func RegisterJobs(reg *jobs.Registry, s *Service)

RegisterJobs adds the hub's workers and periodic jobs.

func SampleData

func SampleData(event string) map[string]any

SampleData is the data of a sample event, shaped like the real ones.

func StatusSignature

func StatusSignature(keyHash []byte, ts int64) string

StatusSignature signs a "Check now" call with one of a site's keys: the hex HMAC-SHA256 of "{timestamp}.status", keyed with the key's SHA-256. ReputeCast keeps only that hash; the plugin computes it from the key it holds, so it answers only the workspace it's connected to.

func Valid

func Valid(kind string) bool

Valid reports whether kind can be connected.

Types

type CallRequest

type CallRequest struct {
	Headers map[string]string `json:"headers"`
	Body    json.RawMessage   `json:"body,omitempty"`
}

CallRequest is a logged request: the headers the log shows and the body with its sensitive values masked.

type CallTarget

type CallTarget struct {
	Kind     string `json:"kind"`
	Email    string `json:"email,omitempty"`
	List     string `json:"list,omitempty"`
	Tag      string `json:"tag,omitempty"`
	Event    string `json:"event,omitempty"`
	Template string `json:"template,omitempty"`
	Endpoint string `json:"endpoint,omitempty"`
	Title    string `json:"title,omitempty"`
	Version  string `json:"version,omitempty"`
}

CallTarget says what a call was about. Kind picks the sentence the app shows ("payment-failed to finance@initech.example"); Email is replaced by "a contact" for members without subscribers:view.

type Confirmations

type Confirmations interface {
	SendConfirmations(ctx context.Context, ws *store.Workspace, ids []uuid.UUID) (int, error)
}

Confirmations sends double opt-in emails (internal/audience).

type ContactEventsArgs

type ContactEventsArgs struct{}

ContactEventsArgs turns queued contact events (contact.subscribed, .unsubscribed, .updated) into webhook deliveries.

func (ContactEventsArgs) InsertOpts

func (ContactEventsArgs) InsertOpts() river.InsertOpts

InsertOpts keeps one run at a time on the events queue.

func (ContactEventsArgs) Kind

func (ContactEventsArgs) Kind() string

Kind implements river.JobArgs.

type ContactEventsWorker

type ContactEventsWorker struct {
	river.WorkerDefaults[ContactEventsArgs]
	S *Service
}

ContactEventsWorker delivers queued contact events.

func (*ContactEventsWorker) Work

Work implements river.Worker.

type ContactListAddInput

type ContactListAddInput struct {
	Email   string `json:"email" minLength:"3" maxLength:"254"`
	Consent string `json:"consent,omitempty" enum:"single,double"`
}

ContactListAddInput adds an existing contact to a list.

type ContactListJoin

type ContactListJoin struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status" enum:"subscribed,pending"`
}

ContactListJoin is a list a contact is now on.

type ContactTagInput

type ContactTagInput struct {
	Email string   `json:"email" minLength:"3" maxLength:"254"`
	Tags  []string `json:"tags" minItems:"1" maxItems:"50"`
}

ContactTagInput adds tags to an existing contact.

type ContactUpsertInput

type ContactUpsertInput struct {
	Email     string  `json:"email" minLength:"3" maxLength:"254" example:"rob@example.net"`
	FirstName *string `json:"firstName,omitempty" maxLength:"100"`
	LastName  *string `json:"lastName,omitempty" maxLength:"100"`
	Company   *string `json:"company,omitempty" maxLength:"200"`
	// Language is a BCP 47 code ("es-MX"); "Spanish" and "es_MX" are
	// accepted and normalized.
	Language *string `json:"language,omitempty" maxLength:"40"`
	// Fields sets custom fields by key; null clears one.
	Fields map[string]any `json:"fields,omitempty"`
	// Tags are added to the contact's tags.
	Tags []string `json:"tags,omitempty" maxItems:"50"`
	// Lists are list ids to add the contact to.
	Lists []string `json:"lists,omitempty" maxItems:"20"`
	// Consent: single adds them to the lists now; double sends a
	// confirmation email first. Without it, each list's own setting applies.
	Consent string `json:"consent,omitempty" enum:"single,double"`
}

ContactUpsertInput creates or updates a contact, matched by email.

type ContactUpsertResult

type ContactUpsertResult struct {
	ContactID string            `json:"contactId"`
	Email     string            `json:"email"`
	Created   bool              `json:"created"`
	Lists     []ContactListJoin `json:"lists"`
	Tags      []string          `json:"tags"`
	// ConfirmationSent: a double opt-in email went out.
	ConfirmationSent bool `json:"confirmationSent"`
}

ContactUpsertResult is what an action did to a contact.

type DraftLanguages

type DraftLanguages interface {
	// Add writes the draft in the post's language (source), when the
	// workspace offers it and the draft has no versions yet, then adds the
	// versions the workspace offers that the draft doesn't have, marked up
	// to date. It returns the languages added.
	Add(ctx context.Context, ws *store.Workspace, p *authz.Principal, campaignID uuid.UUID, source string, versions []DraftVersion) ([]string, error)
}

DraftLanguages writes a post draft's languages (plugin 1.3.0). The content-languages domain implements it; without it a draft has one language.

type DraftVersion

type DraftVersion struct {
	Language  string
	Subject   string
	Preheader string
	MJML      string
	HTML      string
	Label     string
}

DraftVersion is a language version of a post's draft: a translation's subject, preheader and content.

type Group

type Group struct {
	Key string
	// Kinds of entries the group lists. A group with nothing in it isn't
	// shown; later phases add AI models, verification, payments and commerce.
	Entries []string
}

Group is a group of the catalog, in display order.

type GroupSource

type GroupSource func(ctx context.Context, ws *store.Workspace) ([]IntegrationEntry, error)

GroupSource returns the cards another domain adds to a catalog group.

type IntegrationAIFacts

type IntegrationAIFacts struct {
	ModelName  string  `json:"modelName,omitempty"`
	CostMicros int64   `json:"costMicros"`
	Tokens     int64   `json:"tokens"`
	CapKind    string  `json:"capKind,omitempty" enum:"usd,tokens,none,"`
	CapUSD     float64 `json:"capUsd"`
	CapTokens  int64   `json:"capTokens"`
	Share      float64 `json:"share" doc:"Share of the cap used, 0 to 1"`
	// Connected names the provider connected to the workspace, when it is
	// another one: one model per workspace.
	Connected string `json:"connected,omitempty"`
	// KeyRejected: the provider rejected the saved key.
	KeyRejected bool `json:"keyRejected"`
}

IntegrationAIFacts are an AI model card's facts: the model connected, and this month's use against the cap.

type IntegrationAddressCheck

type IntegrationAddressCheck struct {
	Address string `json:"address"`
	Host    string `json:"host"`
	// Resolves is the first address the host resolves to.
	Resolves string `json:"resolves,omitempty"`
	Private  bool   `json:"private"`
	// Allowed: webhooks may reach it (public, or private ones are allowed).
	Allowed bool     `json:"allowed"`
	Admins  []string `json:"admins"`
}

IntegrationAddressCheck is what ReputeCast sees of a workflow tool's address.

type IntegrationAddressCheckInput

type IntegrationAddressCheckInput struct {
	Address string `json:"address" maxLength:"300" example:"https://n8n.acme.io"`
}

IntegrationAddressCheckInput checks a workflow tool's address.

type IntegrationAddressInput

type IntegrationAddressInput struct {
	Address string `json:"address" maxLength:"300" example:"https://n8n.acme.io" doc:"Empty to forget it"`
}

IntegrationAddressInput is n8n's address, set while connecting.

type IntegrationAlert

type IntegrationAlert struct {
	Entry        string            `json:"entry"`
	ConnectionID string            `json:"connectionId,omitempty"`
	Reason       IntegrationReason `json:"reason"`
	// Address is n8n's address, for "Open n8n".
	Address string `json:"address,omitempty"`
}

IntegrationAlert is a banner: an entry and its reason.

type IntegrationApp

type IntegrationApp struct {
	Kind         string              `json:"kind" enum:"zapier,make,n8n"`
	Status       string              `json:"status" enum:"not_connected,waiting,connected,attention"`
	Reasons      []IntegrationReason `json:"reasons"`
	ConnectionID string              `json:"connectionId,omitempty"`
	Label        string              `json:"label,omitempty"`
	ConnectedBy  *IntegrationPerson  `json:"connectedBy,omitempty"`
	ConnectedAt  *time.Time          `json:"connectedAt,omitempty"`
	// Address is n8n's address ("https://n8n.acme.io").
	Address   string                   `json:"address,omitempty"`
	Numbers   IntegrationNumbers       `json:"numbers"`
	Workflows []IntegrationWorkflowRow `json:"workflows"`
	Webhooks  []IntegrationManagedHook `json:"webhooks"`
	Items     []IntegrationItemState   `json:"items"`
	Key       *IntegrationKeyView      `json:"key,omitempty"`
	// OldKey is the rotated key while it still works.
	OldKey      *IntegrationKeyView `json:"oldKey,omitempty"`
	InstanceURL string              `json:"instanceUrl"`
	// Receives lists the triggers in use (with a managed webhook).
	Receives []string `json:"receives"`
	// Rejected are the calls refused since the key stopped working.
	Rejected []IntegrationRejectedCall `json:"rejected"`
	// FirstCall is the key's first call (the waiting timeline).
	FirstCall    *IntegrationFirstCall   `json:"firstCall,omitempty"`
	Reachability IntegrationReachability `json:"reachability"`
	CanManage    bool                    `json:"canManage"`
	Helpers      []string                `json:"helpers"`
	Triggers     int                     `json:"triggers"`
	Actions      int                     `json:"actions"`
}

IntegrationApp is an automation platform's page (Zapier, Make, n8n).

type IntegrationAttempt

type IntegrationAttempt struct {
	Event       string     `json:"event"`
	Attempt     int32      `json:"attempt"`
	MaxAttempts int32      `json:"maxAttempts"`
	Status      *int32     `json:"status,omitempty"`
	StatusText  string     `json:"statusText,omitempty"`
	At          *time.Time `json:"at,omitempty"`
	Queued      int64      `json:"queued"`
}

IntegrationAttempt is one delivery attempt of a failing managed webhook.

type IntegrationCallDetail

type IntegrationCallDetail struct {
	Call     IntegrationCallView `json:"call"`
	Headers  map[string]string   `json:"headers"`
	Request  json.RawMessage     `json:"request,omitempty"`
	Response json.RawMessage     `json:"response,omitempty"`
}

IntegrationCallDetail is one call with its request and response, secrets masked and addresses shown by permission.

type IntegrationCallFilter

type IntegrationCallFilter struct {
	ErrorsOnly bool
	Window     string // 24h or 7d
	Offset     int
	Limit      int
}

IntegrationCallFilter narrows the call log.

type IntegrationCallList

type IntegrationCallList struct {
	Items  []IntegrationCallView `json:"items"`
	Total  int64                 `json:"total" doc:"Calls in the window"`
	Errors int64                 `json:"errors" doc:"Errors in the window"`
	Offset int                   `json:"offset"`
	Limit  int                   `json:"limit"`
}

IntegrationCallList is a page of the call log.

type IntegrationCallView

type IntegrationCallView struct {
	ID         string     `json:"id"`
	At         time.Time  `json:"at"`
	Workflow   string     `json:"workflow"`
	Unnamed    bool       `json:"unnamed"`
	Item       string     `json:"item,omitempty"`
	Operation  string     `json:"operation"`
	Method     string     `json:"method"`
	Path       string     `json:"path"`
	Status     int32      `json:"status"`
	Code       string     `json:"code,omitempty"`
	Detail     string     `json:"detail,omitempty"`
	DurationMs int32      `json:"durationMs"`
	Target     CallTarget `json:"target"`
	// Who is whether the target's address is shown: email, contact (the
	// member can't see contacts), erased, or none.
	Who        string                 `json:"who" enum:"email,contact,erased,none"`
	Missing    []string               `json:"missing,omitempty"`
	Resolution *IntegrationResolution `json:"resolution,omitempty"`
	IP         string                 `json:"ip,omitempty"`
	Client     string                 `json:"client,omitempty"`
}

IntegrationCallView is one call of the log.

type IntegrationChangeInput

type IntegrationChangeInput struct {
	Items []string `json:"items" maxItems:"20"`
	Lists []string `json:"lists,omitempty" maxItems:"100"`
}

IntegrationChangeInput changes what an integration can do.

type IntegrationChanged

type IntegrationChanged struct {
	Items       []string `json:"items"`
	Permissions []string `json:"permissions"`
	// WebhooksRemoved counts managed webhooks of triggers turned off.
	WebhooksRemoved int `json:"webhooksRemoved"`
}

IntegrationChanged reports a change of what an integration can do.

type IntegrationConnectInfo

type IntegrationConnectInfo struct {
	Kind  string                  `json:"kind"`
	Items []IntegrationItemLock   `json:"items"`
	Lists []access.ScopedList     `json:"lists"`
	Name  string                  `json:"name" doc:"The suggested key name, \"Make · Acme ops\""`
	Reach IntegrationReachability `json:"reachability"`
	// ConnectionID is set when reconnecting a connection whose key stopped.
	ConnectionID string `json:"connectionId,omitempty"`
	InstanceURL  string `json:"instanceUrl"`
	// Order and Includes let the dialog show the key's permissions as the
	// switches change: in this order, leaving out a permission another one
	// includes ("subscribers:edit includes subscribers:view").
	Order    []string            `json:"order"`
	Includes map[string][]string `json:"includes"`
}

IntegrationConnectInfo is the connect dialog's first step.

type IntegrationConnectInput

type IntegrationConnectInput struct {
	Items     []string   `json:"items,omitempty" maxItems:"20" doc:"Catalog keys of the triggers and actions turned on"`
	Name      string     `json:"name,omitempty" maxLength:"80" doc:"The key's name, \"Make · Acme ops\""`
	Lists     []string   `json:"lists,omitempty" maxItems:"100" doc:"Limit the key to these lists; empty for all lists"`
	ExpiresAt *time.Time `json:"expiresAt,omitempty"`
	// Address is n8n's address (to open it and check that ReputeCast can
	// reach it), or the WordPress site's.
	Address string `json:"address,omitempty" maxLength:"300"`
}

IntegrationConnectInput connects an integration: what it may do, its key's name, list scope and expiry.

type IntegrationDeadLetter

type IntegrationDeadLetter struct {
	ID          string     `json:"id"`
	Event       string     `json:"event"`
	Email       string     `json:"email,omitempty"`
	FirstTryAt  time.Time  `json:"firstTryAt"`
	LastAnswer  *int32     `json:"lastAnswer,omitempty"`
	StatusText  string     `json:"statusText,omitempty"`
	Error       string     `json:"error,omitempty"`
	KeptUntil   time.Time  `json:"keptUntil"`
	LastAttempt *time.Time `json:"lastAttempt,omitempty"`
}

IntegrationDeadLetter is a delivery waiting in the dead-letter queue.

type IntegrationDeadLetterList

type IntegrationDeadLetterList struct {
	Items []IntegrationDeadLetter `json:"items"`
}

IntegrationDeadLetterList is a managed webhook's dead-letter queue.

type IntegrationDisconnectInput

type IntegrationDisconnectInput struct {
	Reason string `json:"reason,omitempty" maxLength:"300"`
}

IntegrationDisconnectInput says why, for the audit log.

type IntegrationDisconnectPreview

type IntegrationDisconnectPreview struct {
	Workflows []IntegrationWorkflowRef `json:"workflows" doc:"Workflows seen in the last 30 days: they stop"`
	Key       *IntegrationKeyView      `json:"key,omitempty"`
	Webhooks  int64                    `json:"webhooks"`
	Queued    int64                    `json:"queued"`
	Dead      int64                    `json:"dead"`
}

IntegrationDisconnectPreview is what disconnecting stops, removes and keeps.

type IntegrationEntry

type IntegrationEntry struct {
	Key string `` /* 208-byte string literal not displayed */
	// Status: not_connected, waiting, connected, attention; none for the
	// developer cards.
	Status          string              `json:"status" enum:"not_connected,waiting,connected,attention,none"`
	UpdateAvailable bool                `json:"updateAvailable"`
	ConnectionID    string              `json:"connectionId,omitempty"`
	Reasons         []IntegrationReason `json:"reasons"`
	Facts           IntegrationFacts    `json:"facts"`
}

IntegrationEntry is a catalog card: its status, the reason it needs attention, and the facts of its fact line.

type IntegrationFacts

type IntegrationFacts struct {
	Workflows    int64      `json:"workflows"`
	LastCallAt   *time.Time `json:"lastCallAt,omitempty"`
	KeyCreatedAt *time.Time `json:"keyCreatedAt,omitempty"`
	Triggers     int        `json:"triggers"`
	Actions      int        `json:"actions"`
	Sites        int        `json:"sites"`
	SilentSites  int        `json:"silentSites"`
	Updates      int        `json:"updates"`
	Team         string     `json:"team,omitempty"`
	LastSyncAt   *time.Time `json:"lastSyncAt,omitempty"`
	Endpoints    int64      `json:"endpoints"`
	Failing      int64      `json:"failing"`
	MCPEnabled   bool       `json:"mcpEnabled"`
	Agents       int64      `json:"agents"`
	// AI is an AI model's card (the "AI models" group, internal/ai).
	AI *IntegrationAIFacts `json:"ai,omitempty"`
	// Payment is a payment provider's card (the Payments group, Earn).
	Payment *IntegrationPaymentFacts `json:"payment,omitempty"`
	// Balance is a verification service's credits and Price what a check
	// costs on the workspace's plan, when connected.
	Balance *int64  `json:"balance,omitempty"`
	Price   float64 `json:"price,omitempty"`
	// Store is a store platform's card (the Commerce group, X20).
	Store *IntegrationStoreFacts `json:"store,omitempty"`
}

IntegrationFacts feed a card's fact line ("3 Zaps · last call 2 min ago").

type IntegrationFieldItem

type IntegrationFieldItem struct {
	Key   string `json:"key"`
	Label string `json:"label"`
	Type  string `json:"type"`
}

IntegrationFieldItem is a custom field in an app's field mapping.

type IntegrationFieldItems

type IntegrationFieldItems struct {
	Items []IntegrationFieldItem `json:"items"`
}

IntegrationFieldItems are the custom fields the apps map.

type IntegrationFirstCall

type IntegrationFirstCall struct {
	At        time.Time `json:"at"`
	Operation string    `json:"operation"`
	Status    int32     `json:"status"`
	IP        string    `json:"ip,omitempty"`
	Client    string    `json:"client,omitempty"`
}

IntegrationFirstCall is a key's first call.

type IntegrationFormItem

type IntegrationFormItem struct {
	ID     string `json:"id" example:"frm_8c2e1a" doc:"The form's ID, as form.submitted's form_id"`
	Name   string `json:"name"`
	Status string `json:"status" enum:"draft,live,paused"`
}

IntegrationFormItem is a signup form, for the Form submitted trigger's form filter in the apps.

type IntegrationFormItems

type IntegrationFormItems struct {
	Items []IntegrationFormItem `json:"items"`
}

IntegrationFormItems are the workspace's signup forms.

type IntegrationGroup

type IntegrationGroup struct {
	Key     string             `json:"key" enum:"automation,websites,deliverability,developer,ai,verification,payments,commerce"`
	Entries []IntegrationEntry `json:"entries"`
}

IntegrationGroup is one group of the catalog.

type IntegrationHook

type IntegrationHook struct {
	ID        string    `json:"id"`
	Event     string    `json:"event"`
	URL       string    `json:"url"`
	CreatedAt time.Time `json:"createdAt"`
	Secret    string    `json:"secret,omitempty" doc:"The signing secret. Only in the answer to the subscribe call."`
	// SignatureHeader and TimestampHeader name the headers to verify.
	SignatureHeader string `json:"signatureHeader"`
	TimestampHeader string `json:"timestampHeader"`
}

IntegrationHook is a managed webhook as its integration sees it. The signing secret goes to the integration once and is never shown again.

type IntegrationHookInput

type IntegrationHookInput struct {
	Event string `json:"event" example:"contact.unsubscribed" doc:"The trigger's event"`
	URL   string `json:"url" maxLength:"500" doc:"Where ReputeCast posts the events: the workflow's webhook address"`
}

IntegrationHookInput subscribes a workflow to a trigger (Zapier's REST Hooks, Make's instant triggers, n8n's webhook node).

type IntegrationHub

type IntegrationHub struct {
	Groups []IntegrationGroup `json:"groups" doc:"Groups with something in them, in order"`
	// Alerts are the problems the banners name, worst first.
	Alerts []IntegrationAlert `json:"alerts"`
	// CanManage: the caller holds integrations:manage; Helpers hold it.
	CanManage bool     `json:"canManage"`
	Helpers   []string `json:"helpers"`
}

IntegrationHub is Settings › Integrations: the catalog.

type IntegrationItemLock

type IntegrationItemLock struct {
	Key         string   `json:"key"`
	Kind        string   `json:"kind" enum:"trigger,action"`
	Event       string   `json:"event,omitempty"`
	Permissions []string `json:"permissions"`
	Sensitive   bool     `json:"sensitive"`
	New         bool     `json:"new"`
	On          bool     `json:"on"`
	Locked      bool     `json:"locked"`
	// Missing is the permission the caller lacks; Helpers hold it.
	Missing string   `json:"missing,omitempty"`
	Helpers []string `json:"helpers,omitempty"`
}

IntegrationItemLock is a trigger or action in the connect dialog: on by default unless it needs a ⚑ permission, locked when the caller doesn't hold what it needs.

type IntegrationItemState

type IntegrationItemState struct {
	Key         string   `json:"key"`
	Kind        string   `json:"kind" enum:"trigger,action"`
	Event       string   `json:"event,omitempty"`
	Permissions []string `json:"permissions"`
	Sensitive   bool     `json:"sensitive"`
	New         bool     `json:"new"`
	On          bool     `json:"on"`
	Available   bool     `json:"available"`
	// OffReason: turned_off (when connecting or since), or owner_lacks (the
	// key's owner doesn't hold Missing).
	OffReason string `json:"offReason,omitempty" enum:"turned_off,owner_lacks,"`
	Missing   string `json:"missing,omitempty"`
	Owner     string `json:"owner,omitempty"`
}

IntegrationItemState is a trigger or action of an integration: whether it's on, available, and why not.

type IntegrationKeyView

type IntegrationKeyView struct {
	ID          string              `json:"id"`
	Name        string              `json:"name"`
	Masked      string              `json:"masked" example:"rc_live_5d1e…7b20"`
	Permissions []string            `json:"permissions" doc:"As held: implied view permissions left out"`
	Sensitive   []string            `json:"sensitive"`
	Scope       access.ScopeSummary `json:"scope"`
	Owner       IntegrationPerson   `json:"owner"`
	// OwnerStatus is active, deactivated or removed.
	OwnerStatus string     `json:"ownerStatus" enum:"active,deactivated,removed"`
	OwnerLeftAt *time.Time `json:"ownerLeftAt,omitempty"`
	CreatedAt   time.Time  `json:"createdAt"`
	ExpiresAt   *time.Time `json:"expiresAt,omitempty"`
	LastUsedAt  *time.Time `json:"lastUsedAt,omitempty"`
	LastUsedIP  string     `json:"lastUsedIp,omitempty"`
	// LastUsedClient is the app ("Zapier, ReputeCast app 1.2.0").
	LastUsedClient string     `json:"lastUsedClient,omitempty"`
	RevokedAt      *time.Time `json:"revokedAt,omitempty"`
	GraceUntil     *time.Time `json:"graceUntil,omitempty" doc:"A rotated key keeps working until then"`
	// Status: active, grace (rotated, still working), revoked or expired.
	Status string `json:"status" enum:"active,grace,revoked,expired"`
}

IntegrationKeyView is an integration's key, without its secret.

type IntegrationKindPath

type IntegrationKindPath struct {
	api.WorkspaceInput
	Kind string `path:"kind" enum:"zapier,make,n8n,wordpress"`
}

IntegrationKindPath names an integration in the path.

type IntegrationListItem

type IntegrationListItem struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	DoubleOptIn bool   `json:"doubleOptIn"`
}

IntegrationListItem is a list in an app's dropdown.

type IntegrationListItems

type IntegrationListItems struct {
	Items []IntegrationListItem `json:"items"`
}

IntegrationListItems are the lists the apps offer.

type IntegrationListOption

type IntegrationListOption struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Contacts int64  `json:"contacts"`
}

IntegrationListOption is a list with its size.

type IntegrationManagedHook

type IntegrationManagedHook struct {
	ID           string     `json:"id"`
	Event        string     `json:"event"`
	Endpoint     string     `json:"endpoint" doc:"Masked: https://n8n.acme.io/webhook/7c1e…/reputecast"`
	CreatedAt    time.Time  `json:"createdAt"`
	Workflow     string     `json:"workflow,omitempty"`
	Delivered24h int64      `json:"delivered24h"`
	Total24h     int64      `json:"total24h"`
	Retrying     int64      `json:"retrying"`
	Queued       int64      `json:"queued"`
	Dead         int64      `json:"dead"`
	Status       string     `json:"status" enum:"new,healthy,failing,dead_letters"`
	FailingSince *time.Time `json:"failingSince,omitempty"`
	LastStatus   *int32     `json:"lastStatus,omitempty"`
	StatusText   string     `json:"statusText,omitempty"`
	NextAt       *time.Time `json:"nextAt,omitempty"`
	// LastAttempt is the oldest delivery's latest attempt while failing.
	LastAttempt *IntegrationAttempt `json:"lastAttempt,omitempty"`
	// RecoveredAt is when a failing endpoint answered 2xx again (dead letters wait).
	RecoveredAt *time.Time `json:"recoveredAt,omitempty"`
}

IntegrationManagedHook is a webhook an integration manages.

type IntegrationManagedKey

type IntegrationManagedKey struct {
	IntegrationKeyView
	ConnectionID string `json:"connectionId"`
	Kind         string `json:"kind"`
	Label        string `json:"label"`
	// Workflows are the workflows that stop if the key is revoked.
	Workflows []IntegrationWorkflowRef `json:"workflows"`
	Calls7d   int64                    `json:"calls7d"`
}

IntegrationManagedKey is a key in Keys & MCP's "Managed by integrations".

type IntegrationManagedKeyList

type IntegrationManagedKeyList struct {
	Items []IntegrationManagedKey `json:"items"`
}

IntegrationManagedKeyList is Keys & MCP's second table.

type IntegrationMe

type IntegrationMe struct {
	Workspace     string   `json:"workspace" doc:"The workspace slug, for the other calls' paths"`
	WorkspaceName string   `json:"workspaceName"`
	Integration   string   `json:"integration" enum:"zapier,make,n8n,wordpress,"`
	Key           string   `json:"key" doc:"The key's name"`
	Triggers      []string `json:"triggers" doc:"Events of the triggers turned on"`
	Actions       []string `json:"actions" doc:"Actions turned on"`
	Permissions   []string `json:"permissions"`
}

IntegrationMe is what "Test connection" returns to the app: the key's workspace and what it can do.

type IntegrationNumbers

type IntegrationNumbers struct {
	Calls7d          int64      `json:"calls7d"`
	Errors7d         int64      `json:"errors7d"`
	Fixed7d          int64      `json:"fixed7d" doc:"Errors a later call from the same workflow got past"`
	ConsentKept7d    int64      `json:"consentKept7d" doc:"Calls refused to keep consent (409)"`
	LastCallAt       *time.Time `json:"lastCallAt,omitempty"`
	LastCallWorkflow string     `json:"lastCallWorkflow,omitempty"`
	ManagedWebhooks  int        `json:"managedWebhooks"`
}

IntegrationNumbers are the four numbers of a page.

type IntegrationOption

type IntegrationOption struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Detail string `json:"detail,omitempty"`
}

IntegrationOption is a choice of a picker.

type IntegrationOwned

type IntegrationOwned struct {
	ConnectionID string `json:"connectionId"`
	Kind         string `json:"kind"`
	Label        string `json:"label"`
	KeyName      string `json:"keyName"`
	Workflows    int64  `json:"workflows" doc:"Workflows seen in the last 30 days"`
	// Silent is when a WordPress site last reported in, if it went quiet.
	SilentSince *time.Time `json:"silentSince,omitempty"`
}

IntegrationOwned is an integration whose key a member owns.

type IntegrationOwnedList

type IntegrationOwnedList struct {
	Items []IntegrationOwned `json:"items"`
	// CanManage: the caller can take them over or disconnect them.
	CanManage bool `json:"canManage"`
}

IntegrationOwnedList is what the deactivate and remove dialogs list.

type IntegrationPath

type IntegrationPath struct {
	api.WorkspaceInput
	ID string `path:"id" format:"uuid"`
}

IntegrationPath names a connection (an app's, or a WordPress site's).

type IntegrationPaymentFacts

type IntegrationPaymentFacts struct {
	Available bool   `json:"available"`
	Account   string `json:"account,omitempty"`
	Mode      string `json:"mode,omitempty" enum:"live,test,"`
}

IntegrationPaymentFacts are a payment provider card's facts: whether it is available yet, and the account and mode once connected ("Acme Media · Live").

type IntegrationPerson

type IntegrationPerson struct {
	ID          string `json:"id,omitempty"`
	Name        string `json:"name"`
	AvatarColor string `json:"avatarColor,omitempty"`
}

IntegrationPerson is a member named on an integration.

type IntegrationReachability

type IntegrationReachability struct {
	URL string `json:"url"`
	// Private: the public URL is a private, loopback or local address.
	Private   bool               `json:"private"`
	Reachable bool               `json:"reachable"`
	CheckedAt *time.Time         `json:"checkedAt,omitempty"`
	DNS       accounts.CheckLine `json:"dns"`
	TLS       accounts.CheckLine `json:"tls"`
	Reach     accounts.CheckLine `json:"reach"`
	// Admins are the instance admins, who can give the instance a public
	// address or allow webhooks to private addresses.
	Admins []string `json:"admins"`
	// PrivateWebhooks: webhooks may go to private addresses on this server.
	PrivateWebhooks bool `json:"privateWebhooks"`
}

IntegrationReachability is the public URL check as Zapier and Make see it.

type IntegrationReason

type IntegrationReason struct {
	Code string `json:"code" enum:"key_revoked,key_expired,owner_left,key_expiring,deliveries_failing,calls_failing,site_silent"`
	// Since is when it started (revoked, expired, left, failing, last heard from).
	Since *time.Time `json:"since,omitempty"`
	// By names who revoked the key, or the member who left.
	By string `json:"by,omitempty"`
	// Site or endpoint host ("staging.acme.io", "n8n.acme.io").
	Host string `json:"host,omitempty"`
	// ConnectionID is the connection (a WordPress site) it is about.
	ConnectionID string `json:"connectionId,omitempty"`
	// Rejected counts calls refused since; Status and StatusText are the
	// failing endpoint's answer; Retrying and NextAt its queue.
	Rejected   int64      `json:"rejected,omitempty"`
	Status     int32      `json:"status,omitempty"`
	StatusText string     `json:"statusText,omitempty"`
	Retrying   int64      `json:"retrying,omitempty"`
	NextAt     *time.Time `json:"nextAt,omitempty"`
	Calls      int64      `json:"calls,omitempty"`
	Failed     int64      `json:"failed,omitempty"`
	// Check is the last "Check now" of a silent site.
	Check *WordPressCheck `json:"check,omitempty"`
}

IntegrationReason is why an integration needs attention, with what the sentence about it needs.

type IntegrationRejectedCall

type IntegrationRejectedCall struct {
	At       time.Time `json:"at"`
	Workflow string    `json:"workflow"`
	Status   int32     `json:"status"`
	Code     string    `json:"code"`
}

IntegrationRejectedCall is a call refused because the key stopped working.

type IntegrationResolution

type IntegrationResolution struct {
	FixedAt   *time.Time  `json:"fixedAt,omitempty"`
	FixedBy   string      `json:"fixedBy,omitempty"`
	LaterRuns []time.Time `json:"laterRuns"`
}

IntegrationResolution says an error is behind us: who fixed it and when, or the later runs that went through.

type IntegrationSecret

type IntegrationSecret struct {
	IntegrationID string             `json:"integrationId"`
	Kind          string             `json:"kind"`
	Key           IntegrationKeyView `json:"key"`
	Secret        string             `json:"secret" doc:"The full key. Shown only in this response."`
	InstanceURL   string             `json:"instanceUrl" doc:"Paste it into the other tool with the key"`
	// OldKeyUntil is when a rotated key stops working.
	OldKeyUntil *time.Time `json:"oldKeyUntil,omitempty"`
}

IntegrationSecret carries a new key, shown once.

type IntegrationSite

type IntegrationSite struct {
	ID              string                 `json:"id" doc:"The connection's id"`
	Host            string                 `json:"host"`
	SiteURL         string                 `json:"siteUrl,omitempty"`
	Name            string                 `json:"name,omitempty"`
	Status          string                 `json:"status" enum:"waiting,connected,attention"`
	UpdateAvailable bool                   `json:"updateAvailable"`
	PluginVersion   string                 `json:"pluginVersion,omitempty"`
	WPVersion       string                 `json:"wordpressVersion,omitempty"`
	PHPVersion      string                 `json:"phpVersion,omitempty"`
	FirstReportAt   *time.Time             `json:"firstReportAt,omitempty"`
	LastReportAt    *time.Time             `json:"lastReportAt,omitempty"`
	LastCheck       *WordPressCheck        `json:"lastCheck,omitempty"`
	FeedURL         string                 `json:"feedUrl,omitempty"`
	LanguagePlugin  string                 `json:"languagePlugin,omitempty"`
	Forms           []IntegrationSiteForm  `json:"forms"`
	Categories      []WordPressCategory    `json:"categories"`
	Rule            IntegrationSiteRule    `json:"rule"`
	Drafts          []IntegrationSiteDraft `json:"drafts"`
	DraftsThisWeek  int64                  `json:"draftsThisWeek"`
	Key             *IntegrationKeyView    `json:"key,omitempty"`
	OldKey          *IntegrationKeyView    `json:"oldKey,omitempty"`
	Items           []IntegrationItemState `json:"items"`
	ConnectedBy     string                 `json:"connectedBy,omitempty"`
	ConnectedAt     time.Time              `json:"connectedAt"`
	Reasons         []IntegrationReason    `json:"reasons"`
	// SignupsRejected: a form used on the site doesn't allow it.
	SignupsRejected bool `json:"signupsRejected"`
	// WooCommerce is "WooCommerce detected": the plugin's checkout consent
	// and abandoned-checkout reporting, and the store connected at the
	// site's address.
	WooCommerce *IntegrationSiteWoo `json:"woocommerce,omitempty"`
}

IntegrationSite is a connected WordPress site.

type IntegrationSiteDraft

type IntegrationSiteDraft struct {
	CampaignID  string     `json:"campaignId,omitempty"`
	Title       string     `json:"title"`
	Status      string     `json:"status" doc:"The campaign's status (draft, scheduled, sent…)"`
	Audience    string     `json:"audience,omitempty"`
	PublishedAt *time.Time `json:"publishedAt,omitempty"`
	CreatedAt   time.Time  `json:"createdAt"`
	Notified    string     `json:"notified,omitempty"`
	PostURL     string     `json:"postUrl,omitempty"`
}

IntegrationSiteDraft is a draft created from a post.

type IntegrationSiteForm

type IntegrationSiteForm struct {
	ID      string               `json:"id" doc:"The form's uuid, for links"`
	Public  string               `json:"publicId" example:"frm_8c2e1a"`
	Name    string               `json:"name"`
	Kind    string               `json:"kind" enum:"block,shortcode,widget"`
	Places  []WordPressFormPlace `json:"places"`
	Allowed bool                 `json:"allowed" doc:"The site is one of the form's allowed domains"`
	Missing bool                 `json:"missing" doc:"The site uses a form that no longer exists"`
}

IntegrationSiteForm is a signup form used on a site.

type IntegrationSiteRule

type IntegrationSiteRule struct {
	Enabled    bool                   `json:"enabled"`
	Set        bool                   `json:"set" doc:"A rule was set up (even if it's off now)"`
	Categories []WordPressCategory    `json:"categories"`
	List       *IntegrationListOption `json:"list,omitempty"`
	ListIDs    []string               `json:"listIds"`
	Template   *IntegrationOption     `json:"template,omitempty"`
	Sender     *IntegrationOption     `json:"sender,omitempty"`
	Notify     *IntegrationOption     `json:"notify,omitempty"`
}

IntegrationSiteRule is a site's post-draft rule, with names.

type IntegrationSiteWoo

type IntegrationSiteWoo struct {
	Version   string `json:"version"`
	Consent   bool   `json:"consent"`
	Checkouts bool   `json:"checkouts"`
	// StoreID and StoreName are the store connected at the site's address.
	StoreID     string `json:"storeId,omitempty"`
	StoreName   string `json:"storeName,omitempty"`
	StoreStatus string `json:"storeStatus,omitempty" enum:"connecting,importing,connected,disconnected,"`
}

IntegrationSiteWoo is WooCommerce on a WordPress site.

type IntegrationStatus

type IntegrationStatus struct {
	Status       string                `json:"status" enum:"waiting,connected,attention"`
	KeyCreatedAt *time.Time            `json:"keyCreatedAt,omitempty"`
	FirstCall    *IntegrationFirstCall `json:"firstCall,omitempty"`
	// Reported is a WordPress site's first report.
	Reported *time.Time `json:"reported,omitempty"`
}

IntegrationStatus is what the connect dialog's last step polls.

type IntegrationStoreFacts

type IntegrationStoreFacts struct {
	Stores      int        `json:"stores"`
	Name        string     `json:"name"`
	State       string     `json:"state" enum:"connecting,importing,connected,webhook_missing,rate_limited,no_plugin,revoked"`
	Orders      int64      `json:"orders"`
	LastEventAt *time.Time `json:"lastEventAt,omitempty"`
}

IntegrationStoreFacts are a store platform's fact line: its stores, the one the card names, how its sync stands and its orders in 30 days.

type IntegrationTakeOverPreview

type IntegrationTakeOverPreview struct {
	Key      IntegrationKeyView `json:"key"`
	NewOwner IntegrationPerson  `json:"newOwner"`
	RoleName string             `json:"roleName"`
	// Held and Missing split the key's permissions by whether the new owner
	// holds them; Stops lists the triggers and actions that stop.
	Held    []string `json:"held"`
	Missing []string `json:"missing"`
	Stops   []string `json:"stops"`
}

IntegrationTakeOverPreview is what taking over a key would change.

type IntegrationTemplateItem

type IntegrationTemplateItem struct {
	Key       string                        `json:"key" example:"payment-failed" doc:"The template's ID, for the send call"`
	Name      string                        `json:"name"`
	Version   int32                         `json:"version" doc:"The live version"`
	Variables []IntegrationTemplateVariable `json:"variables"`
}

IntegrationTemplateItem is a published transactional template.

type IntegrationTemplateItems

type IntegrationTemplateItems struct {
	Items []IntegrationTemplateItem `json:"items"`
}

IntegrationTemplateItems lists the templates "Send a transactional email" can send.

type IntegrationTemplateVariable

type IntegrationTemplateVariable struct {
	Name        string `json:"name" example:"amount_due"`
	Type        string `json:"type" example:"text"`
	Required    bool   `json:"required"`
	Sensitive   bool   `json:"sensitive" doc:"Masked in the call log, never stored"`
	Description string `json:"description,omitempty"`
}

IntegrationTemplateVariable is one variable of a transactional template, as the apps map it.

type IntegrationTriggerSample

type IntegrationTriggerSample struct {
	Event   string            `json:"event"`
	Payload webhooks.Envelope `json:"payload"`
}

IntegrationTriggerSample is a sample delivery of a trigger, for the apps' field mapping (Zapier's performList, Make's sample, n8n's test step).

type IntegrationWordPressPage

type IntegrationWordPressPage struct {
	Status          string              `json:"status" enum:"not_connected,waiting,connected,attention"`
	Reasons         []IntegrationReason `json:"reasons"`
	UpdateAvailable bool                `json:"updateAvailable"`
	// ConnectedBy names who connected the sites when one person did.
	ConnectedBy  string            `json:"connectedBy,omitempty"`
	LatestPlugin string            `json:"latestPlugin"`
	Sites        []IntegrationSite `json:"sites"`
	// What the post-draft rule dialog offers.
	Templates []IntegrationOption     `json:"templates"`
	Senders   []IntegrationOption     `json:"senders"`
	Lists     []IntegrationListOption `json:"lists"`
	Members   []IntegrationOption     `json:"members"`
	CanManage bool                    `json:"canManage"`
	// CanEditForms: the caller can allow a site on a form (forms:edit).
	CanEditForms bool     `json:"canEditForms"`
	Helpers      []string `json:"helpers"`
	InstanceURL  string   `json:"instanceUrl"`
}

IntegrationWordPressPage is Settings › Integrations › WordPress.

type IntegrationWorkflowRef

type IntegrationWorkflowRef struct {
	Name      string    `json:"name"`
	Unnamed   bool      `json:"unnamed"`
	LastRunAt time.Time `json:"lastRunAt"`
}

IntegrationWorkflowRef is a workflow named in a dialog.

type IntegrationWorkflowRow

type IntegrationWorkflowRow struct {
	Key     string        `json:"key"`
	Name    string        `json:"name"`
	Unnamed bool          `json:"unnamed"`
	Uses    []WorkflowUse `json:"uses"`
	Calls7d int64         `json:"calls7d"`
	// Errors7d splits into failures (FixedAt when later runs went through)
	// and calls refused to keep consent.
	Errors7d      int64      `json:"errors7d"`
	ConsentKept7d int64      `json:"consentKept7d"`
	FixedAt       *time.Time `json:"fixedAt,omitempty"`
	LastRunAt     time.Time  `json:"lastRunAt"`
	// Deliveries7d counts what its trigger's managed webhook delivered.
	Deliveries7d int64 `json:"deliveries7d"`
	Trigger      bool  `json:"trigger"`
}

IntegrationWorkflowRow is a workflow seen in the last 30 days.

type Item

type Item struct {
	Key  string
	Kind string // trigger | action
	// Event is the webhook event of a trigger.
	Event string
	// Permissions the key needs for it; ⚑ ones start off when connecting.
	Permissions []authz.Permission
	// Operations it calls.
	Operations []string
	// New marks items added in this release ("New" badge).
	New bool
}

Item is a trigger or an action an integration can be given.

func ItemByKey

func ItemByKey(kind, key string) (Item, bool)

ItemByKey returns one item of a kind.

func Items

func Items(kind string) []Item

Items returns the triggers and actions of a kind.

func (Item) Sensitive

func (it Item) Sensitive() bool

Sensitive reports whether the item needs a ⚑ permission.

type MaintenanceArgs

type MaintenanceArgs struct{}

MaintenanceArgs drops calls older than 7 days, workflows not seen for 30, and the bodies of calls about contacts erased since; then recomputes which integrations need attention.

func (MaintenanceArgs) InsertOpts

func (MaintenanceArgs) InsertOpts() river.InsertOpts

InsertOpts runs it on the maintenance queue, once at a time.

func (MaintenanceArgs) Kind

func (MaintenanceArgs) Kind() string

Kind implements river.JobArgs.

type MaintenanceWorker

type MaintenanceWorker struct {
	river.WorkerDefaults[MaintenanceArgs]
	S *Service
}

MaintenanceWorker runs MaintenanceArgs.

func (*MaintenanceWorker) Work

Work implements river.Worker.

type PluginReleaseArgs

type PluginReleaseArgs struct{}

PluginReleaseArgs fetches the latest WordPress plugin version with the daily update check (Instance admin › Instance & updates). With the check off, nothing is fetched and pages compare with the version this release knows.

func (PluginReleaseArgs) InsertOpts

func (PluginReleaseArgs) InsertOpts() river.InsertOpts

InsertOpts runs it on the maintenance queue, at most once an hour.

func (PluginReleaseArgs) Kind

func (PluginReleaseArgs) Kind() string

Kind implements river.JobArgs.

type PluginReleaseWorker

type PluginReleaseWorker struct {
	river.WorkerDefaults[PluginReleaseArgs]
	S *Service
	// URL overrides the WordPress plugin directory's API (tests).
	URL string
}

PluginReleaseWorker runs PluginReleaseArgs.

func (*PluginReleaseWorker) Work

Work implements river.Worker.

type Service

type Service struct {
	Pool  *pgxpool.Pool
	Q     *store.Queries
	Audit *audit.Logger
	Box   *secrets.Box
	Log   *slog.Logger
	Cfg   *config.Config
	// PublicURL is the instance's public URL (the saved setting, else http.public_url).
	PublicURL func() string
	URLCheck  URLChecker
	// Confirm sends double opt-in emails for actions that ask for them.
	Confirm Confirmations
	// AllowPrivate reports whether webhooks may reach private addresses
	// (webhooks.allow_private_networks).
	AllowPrivate func() bool
	// Languages turns a post's translations into its draft's language
	// versions (WordPress plugin 1.3.0).
	Languages DraftLanguages
	// Sources fill catalog groups from other domains (AI models from
	// internal/ai, Verification from internal/verification), keyed by group.
	Sources map[string]GroupSource
	// HTTP overrides the client of "Check now" and the release check (tests).
	HTTP *http.Client
	// CheckTimeout overrides how long "Check now" waits (10 s).
	CheckTimeout time.Duration
	Now          func() time.Time
	// PostReported hears of each post a connected WordPress site reports
	// (recurring digests read the site's feed at once); nil does nothing.
	PostReported func(ctx context.Context, siteID uuid.UUID)
}

Service is the integrations hub.

func (*Service) AddToList

AddToList adds an existing contact to a list, single or double opt-in.

func (*Service) App

App builds an automation platform's page.

func (*Service) Call

func (s *Service) Call(ctx context.Context, ws *store.Workspace, p *authz.Principal, id, callID uuid.UUID) (IntegrationCallDetail, error)

Call returns one call of the log.

func (*Service) Calls

Calls returns a page of a connection's call log.

func (*Service) Change

Change updates the key's permissions in place: nothing to paste again. Triggers turned off lose their managed webhooks.

func (*Service) CheckAddress

func (s *Service) CheckAddress(ctx context.Context, raw string) (IntegrationAddressCheck, error)

CheckAddress tells whether triggers can reach a workflow tool's address (n8n on a private network needs an instance admin to allow it).

func (*Service) CheckHealth

func (s *Service) CheckHealth(ctx context.Context) error

CheckHealth recomputes every connection's reasons and notifies members with integrations:manage about new ones, once per reason.

func (*Service) CheckReachability

func (s *Service) CheckReachability(ctx context.Context) (IntegrationReachability, error)

CheckReachability runs the public URL check again and keeps the result, as Instance admin's "Check" does.

func (*Service) CheckSite

func (s *Service) CheckSite(ctx context.Context, ws *store.Workspace, id uuid.UUID) (WordPressCheck, error)

CheckSite calls the site's status endpoint once, through the SSRF guard. ReputeCast never polls a site on a schedule.

func (*Service) Connect

Connect creates an integration's key with the triggers and actions turned on. The key is shown once; the integration waits for its first call.

func (*Service) ConnectInfo

func (s *Service) ConnectInfo(ctx context.Context, ws *store.Workspace, p *authz.Principal, kind string) (IntegrationConnectInfo, error)

ConnectInfo prepares the connect dialog for the caller.

func (*Service) ConnectionID

func (s *Service) ConnectionID(ctx context.Context, ws *store.Workspace, kind string) (uuid.UUID, error)

ConnectionID finds the active connection of a platform, or a WordPress site by its id.

func (*Service) CreateDraft

CreateDraft turns a published post into a campaign draft when the site's rule says so. Drafts only: nobody gets anything until a person reviews and sends it through Send Readiness and approvals as usual.

func (*Service) DeadLetters

func (s *Service) DeadLetters(ctx context.Context, ws *store.Workspace, p *authz.Principal, id, hookID uuid.UUID) (IntegrationDeadLetterList, error)

DeadLetters lists a managed webhook's dead-lettered deliveries.

func (*Service) DefaultLabel

func (s *Service) DefaultLabel(ctx context.Context, ws *store.Workspace) string

DefaultLabel suggests the label of a new key: the one the last automation platform was connected with ("Acme ops"), else the workspace's name.

func (*Service) DeliverContactEvents

func (s *Service) DeliverContactEvents(ctx context.Context, limit int) (int, error)

DeliverContactEvents queues webhook deliveries for up to limit contact events, with the contact as it is now. It returns how many it took.

func (*Service) Disconnect

Disconnect revokes the key at once and deletes the managed webhooks with their queued and dead-letter deliveries. Contacts, events and messages created through the integration stay.

func (*Service) DisconnectPreview

func (s *Service) DisconnectPreview(ctx context.Context, ws *store.Workspace, id uuid.UUID) (IntegrationDisconnectPreview, error)

DisconnectPreview lists what stops, what's removed and what stays.

func (*Service) Fields

Fields returns the custom fields, for the apps' field mapping.

func (*Service) Forms

Forms lists the workspace's signup forms for the block and the shortcode. The key reads forms only: never contacts.

func (*Service) Gone

func (s *Service) Gone(ctx context.Context, webhookID uuid.UUID)

Gone removes a managed webhook whose endpoint answered 410 Gone, as Zapier's REST Hooks ask. The system is the actor.

func (*Service) Hook

func (s *Service) Hook(ctx context.Context, hookID uuid.UUID) (IntegrationHook, error)

Hook returns one of the calling integration's managed webhooks, without its secret: n8n checks that a workflow's webhook still exists whenever the workflow is turned on (or n8n restarts), and subscribes again when it doesn't, for example after a 410 Gone removed it.

func (*Service) Hub

Hub builds the catalog.

func (*Service) Key

func (s *Service) Key(ctx context.Context, id uuid.UUID) (*api.IntegrationKey, error)

Key implements api.Integrations: what an integration key may call.

func (*Service) LatestPlugin

func (s *Service) LatestPlugin(ctx context.Context) string

LatestPlugin returns the newest WordPress plugin version: from the daily update check when it ran, else the one this release knows.

func (*Service) Lists

Lists returns the lists the key's scope reaches, for the apps' dropdowns.

func (*Service) ManagedHook

func (s *Service) ManagedHook(ctx context.Context, webhookID uuid.UUID) (*webhooks.WebhookManagedBy, error)

ManagedHook implements webhooks.Managed for one endpoint.

func (*Service) ManagedHooks

func (s *Service) ManagedHooks(ctx context.Context, workspaceID uuid.UUID) (map[uuid.UUID]webhooks.WebhookManagedBy, error)

ManagedHooks implements webhooks.Managed: the endpoints integrations manage in a workspace.

func (*Service) ManagedKeys

ManagedKeys lists the live keys of the workspace's integrations.

func (*Service) Me

Me describes the calling key.

func (*Service) OwnedBy

OwnedBy lists the integrations whose keys a member owns.

func (*Service) Reachability

func (s *Service) Reachability(ctx context.Context) IntegrationReachability

Reachability says whether apps on the internet can reach the instance, from the public URL and the last check of it.

func (*Service) Reconnect

Reconnect gives a connection whose key was revoked or expired a new key, with what it could do before. It waits for its first call again.

func (*Service) Record

func (s *Service) Record(ctx context.Context, c api.IntegrationCall)

Record implements api.Integrations: it keeps one call in the 7-day log, moves the connection's last call and remembers the workflow. Errors are logged, never returned: the call itself already happened.

func (*Service) Report

Report keeps what a site's plugin reports. The first report connects the site.

func (*Service) Rotate

Rotate gives the integration a new key, shown once. The old one keeps working for 24 hours, so runs don't fail while the new one is pasted.

func (*Service) Sample

Sample returns a sample payload of a trigger that is on.

func (*Service) SetAddress

func (s *Service) SetAddress(ctx context.Context, ws *store.Workspace, id uuid.UUID, raw string) (IntegrationAddressCheck, error)

SetAddress keeps n8n's address, to open it from its page and to check that triggers can reach it. It answers what ReputeCast sees of it.

func (*Service) SetRule

SetRule changes a site's post-draft rule.

func (*Service) Status

func (s *Service) Status(ctx context.Context, ws *store.Workspace, id uuid.UUID) (IntegrationStatus, error)

Status says whether a new key has been called yet.

func (*Service) StopOldKey

func (s *Service) StopOldKey(ctx context.Context, ws *store.Workspace, id uuid.UUID) error

StopOldKey ends a rotated key's grace period at once.

func (*Service) Subscribe

Subscribe creates the managed webhook of a workflow's trigger.

func (*Service) TagContact

TagContact adds tags to an existing contact.

func (*Service) TakeOver

TakeOver makes the caller the owner of the integration's key. The key keeps its value; from now on it's limited by the new owner's permissions.

func (*Service) TakeOverPreview

func (s *Service) TakeOverPreview(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (IntegrationTakeOverPreview, error)

TakeOverPreview lists what the caller holds of the key's permissions.

func (*Service) Templates

Templates lists the published transactional templates and their variables, for "Send a transactional email" in the apps.

func (*Service) TriggerForms

func (s *Service) TriggerForms(ctx context.Context, ws *store.Workspace) (IntegrationFormItems, error)

TriggerForms lists the signup forms, so a workflow can start from one form's submissions only. Only keys with the Form submitted trigger on can call it; it reads forms, never contacts.

func (*Service) Unsubscribe

func (s *Service) Unsubscribe(ctx context.Context, ws *store.Workspace, hookID uuid.UUID) error

Unsubscribe removes a workflow's managed webhook (the workflow was turned off).

func (*Service) UpsertContact

UpsertContact creates or updates a contact matched by email, and adds it to lists without ever adding someone back to a list they left or adding a suppressed address.

func (*Service) WordPressPage

WordPressPage builds the WordPress sites page.

type URLChecker

type URLChecker interface {
	CheckPublicURL(ctx context.Context, raw string) (accounts.URLCheck, error)
}

URLChecker runs the public URL check of Instance admin (DNS, TLS, reachable).

type WordPressCategory

type WordPressCategory struct {
	ID   string `json:"id"`
	Name string `json:"name" maxLength:"200"`
	Slug string `json:"slug" maxLength:"200"`
}

WordPressCategory is a post category of a site, as the plugin reports it.

type WordPressCheck

type WordPressCheck struct {
	OK        bool      `json:"ok"`
	CheckedAt time.Time `json:"checkedAt"`
	// Outcome: the site answered 200, timed out, answered another status,
	// was blocked by the SSRF guard, or couldn't be reached.
	Outcome string `json:"outcome" enum:"answered,timeout,status,blocked,unreachable"`
	// Ms is how long a site took to answer; Seconds the time limit it ran
	// out of; Status the HTTP status it answered.
	Ms      int64   `json:"ms,omitempty"`
	Seconds float64 `json:"seconds,omitempty"`
	Status  int     `json:"status,omitempty"`
	Detail  string  `json:"detail" example:"Timed out after 10 s"`
}

WordPressCheck is the result of "Check now".

type WordPressDraftInput

type WordPressDraftInput struct {
	Post WordPressPost `json:"post"`
}

WordPressDraftInput asks for a campaign draft from a post.

type WordPressDraftResult

type WordPressDraftResult struct {
	Created bool `json:"created"`
	// Reason when nothing was created: no_rule, rule_off, category or
	// exists (the post already has a draft).
	Reason     string `json:"reason,omitempty" enum:"no_rule,rule_off,category,exists,"`
	CampaignID string `json:"campaignId,omitempty"`
	Name       string `json:"name,omitempty"`
	// Languages are the language versions the post's translations added:
	// to the new draft, or to the post's draft when it exists.
	Languages []string `json:"languages,omitempty"`
}

WordPressDraftResult says whether a draft was created, and why not.

type WordPressForm

type WordPressForm struct {
	ID     string `json:"id" example:"frm_8c2e1a"`
	Name   string `json:"name"`
	Status string `json:"status" enum:"draft,live,paused"`
	Kind   string `json:"kind"`
	// SiteAllowed: the calling site is one of the form's allowed domains.
	// The block warns the editor when it isn't.
	SiteAllowed bool   `json:"siteAllowed"`
	Shortcode   string `json:"shortcode" example:"[reputecast_form id=\"frm_8c2e1a\"]"`
	Script      string `json:"script" doc:"The form's public script, as embeds load it"`
}

WordPressForm is a signup form as the plugin's block lists it.

type WordPressFormList

type WordPressFormList struct {
	Items []WordPressForm `json:"items"`
}

WordPressFormList is the workspace's signup forms.

type WordPressFormPlace

type WordPressFormPlace struct {
	Title string `json:"title" maxLength:"200" example:"Join the beta"`
	URL   string `json:"url,omitempty" maxLength:"500"`
}

WordPressFormPlace is where a form is used on a site.

type WordPressFormUse

type WordPressFormUse struct {
	Form   string               `json:"form" maxLength:"40" example:"frm_8c2e1a" doc:"The form's id (frm_…)"`
	Kind   string               `json:"kind" enum:"block,shortcode,widget"`
	Places []WordPressFormPlace `json:"places" maxItems:"100"`
}

WordPressFormUse is how a site uses one signup form.

type WordPressPost

type WordPressPost struct {
	ID          string     `json:"id" maxLength:"64"`
	URL         string     `json:"url,omitempty" maxLength:"1000"`
	Title       string     `json:"title" minLength:"1" maxLength:"300"`
	Excerpt     string     `json:"excerpt,omitempty" maxLength:"2000"`
	ImageURL    string     `json:"imageUrl,omitempty" maxLength:"1000" doc:"The featured image"`
	Categories  []string   `json:"categories,omitempty" maxItems:"100" doc:"Category slugs"`
	PublishedAt *time.Time `json:"publishedAt,omitempty"`
	Language    string     `json:"language,omitempty" maxLength:"40"`
	// Translations (plugin 1.3.0, with WPML or Polylang) become the draft's
	// language versions, marked up to date.
	Translations []WordPressPostTranslation `` /* 149-byte string literal not displayed */
}

WordPressPost is a published post the plugin sends.

type WordPressPostTranslation

type WordPressPostTranslation struct {
	ID       string `json:"id" maxLength:"64"`
	Language string `json:"language" minLength:"2" maxLength:"40" example:"es"`
	URL      string `json:"url,omitempty" maxLength:"1000"`
	Title    string `json:"title" minLength:"1" maxLength:"300"`
	Excerpt  string `json:"excerpt,omitempty" maxLength:"2000"`
	ImageURL string `json:"imageUrl,omitempty" maxLength:"1000"`
}

WordPressPostTranslation is one of a post's translations.

type WordPressReportInput

type WordPressReportInput struct {
	SiteURL          string              `json:"siteUrl" maxLength:"300" example:"https://blog.acme.io"`
	Name             string              `json:"name,omitempty" maxLength:"200"`
	PluginVersion    string              `json:"pluginVersion" maxLength:"20" example:"1.2.0"`
	WordPressVersion string              `json:"wordpressVersion,omitempty" maxLength:"20" example:"6.9.2"`
	PHPVersion       string              `json:"phpVersion,omitempty" maxLength:"20" example:"8.3"`
	FeedURL          string              `json:"feedUrl,omitempty" maxLength:"500"`
	LanguagePlugin   string              `json:"languagePlugin,omitempty" enum:"wpml,polylang,"`
	Categories       []WordPressCategory `json:"categories,omitempty" maxItems:"500"`
	Forms            []WordPressFormUse  `json:"forms,omitempty" maxItems:"100"`
	// WooCommerce is WooCommerce on the site, when it's active (plugin 1.4).
	WooCommerce *WordPressWooCommerce `json:"woocommerce,omitempty"`
}

WordPressReportInput is what the plugin reports: when it connects, every 12 hours and with every post.

type WordPressReportResult

type WordPressReportResult struct {
	Workspace     string `json:"workspace"`
	WorkspaceName string `json:"workspaceName"`
	Site          string `json:"site" doc:"The site's address as ReputeCast lists it"`
	// LatestPlugin is the newest plugin release ReputeCast knows of.
	LatestPlugin string `json:"latestPlugin"`
}

WordPressReportResult tells the plugin where it reported to.

type WordPressRule

type WordPressRule struct {
	Categories   []string `json:"categories" maxItems:"100" doc:"Category slugs"`
	ListIDs      []string `json:"listIds" maxItems:"20"`
	TemplateID   string   `json:"templateId,omitempty" maxLength:"64"`
	SenderID     string   `json:"senderId,omitempty" maxLength:"64"`
	NotifyUserID string   `json:"notifyUserId,omitempty" maxLength:"64"`
}

WordPressRule is a site's post-draft rule.

type WordPressRuleInput

type WordPressRuleInput struct {
	Enabled bool `json:"enabled"`
	WordPressRule
}

WordPressRuleInput sets a site's post-draft rule.

type WordPressWooCommerce

type WordPressWooCommerce struct {
	Version   string `json:"version" maxLength:"20" example:"10.2.1"`
	Consent   bool   `json:"consent" doc:"The consent checkbox is at the checkout"`
	Checkouts bool   `json:"checkouts" doc:"Abandoned checkouts are reported"`
}

WordPressWooCommerce is WooCommerce on a site: its version, and whether the plugin's checkout consent and abandoned-checkout reporting are on.

type Workflow

type Workflow struct {
	ID   string
	Name string
}

Workflow is what X-ReputeCast-Workflow says about the calling workflow.

func ParseWorkflow

func ParseWorkflow(h string) Workflow

ParseWorkflow reads "<name>; id=<id>" (the name may be percent-encoded, or given as name=…). Either part may be missing.

func (Workflow) Key

func (w Workflow) Key() string

Key identifies the workflow in the list: its id, else its name.

func (Workflow) String

func (w Workflow) String() string

String is the header as a person reads it, the name decoded: "Unsubscribes → Acme Cloud CRM; id=wf_2Lm8".

type WorkflowUse

type WorkflowUse struct {
	Item string `json:"item"`
	// Lists, Tags and OptIn describe a contact action.
	Lists []string `json:"lists,omitempty"`
	Tags  []string `json:"tags,omitempty"`
	OptIn string   `json:"optIn,omitempty" enum:"single,double"`
	// Event is the event "Record an event" records; Template the template
	// "Send a transactional email" sends.
	Event    string `json:"event,omitempty"`
	Template string `json:"template,omitempty"`
	// Starts and GoalOf name the live automations the event starts, or
	// that have it as their goal (worked out when the page is read).
	Starts []string `json:"starts,omitempty"`
	GoalOf []string `json:"goalOf,omitempty"`
}

WorkflowUse is one thing a workflow uses: a trigger, or an action with what it was last called with (the app words it: "Beta Program · tag beta-applicant · double opt-in").

Jump to

Keyboard shortcuts

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