campaigns

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: 45 Imported by: 0

Documentation

Overview

Package campaigns implements campaigns: the list and summary, drafts and the composer's storage, versions, scheduling and sending state.

Index

Constants

View Source
const AttrComment = "rc-comment"

AttrComment marks the block a comment thread is on.

View Source
const CodeApprovalWouldCancel = "approval_would_cancel"

CodeApprovalWouldCancel is the 409 a content save gets when the campaign has a pending or approved request: saving cancels it, so the composer asks first (CO-7) and saves again with cancelApproval.

View Source
const CodeVersionConflict = "version_conflict"

CodeVersionConflict is the problem code of an autosave based on an old version.

View Source
const KeepVersions = 300

KeepVersions is how many autosaved versions a campaign keeps; the first version and named saves (⌘S, restores, imports) are always kept.

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

RestoreWindow is how long a deleted campaign can be restored.

View Source
const (
	// ReviewLinkDays is how long a review link works.
	ReviewLinkDays = 7
)

Variables

This section is empty.

Functions

func ContentHash

func ContentHash(subject, preheader, mjmlSrc, html string, ab json.RawMessage) string

ContentHash fingerprints what an approval covers in the content: subject, preheader, MJML, HTML and A/B variants.

func DefaultSender

func DefaultSender(ctx context.Context, q *store.Queries, ws *store.Workspace, p *authz.Principal) *uuid.UUID

DefaultSender is the sender a new draft starts with: the workspace's default, or its first sender, among those its author's scope allows. None when it allows none: a member limited to some sender domains never starts with a From address they couldn't pick, or send from. A new digest's template starts from it too.

func DismissalsOf

func DismissalsOf(ctx context.Context, q *store.Queries, l i18n.Lang, wsID, campaignID uuid.UUID) (map[string]ComposerDismissal, error)

DismissalsOf are a campaign's dismissed warnings by issue key, with the reasons in a reader's language: Send Readiness shows them on Review & send and counts them as acknowledged.

func IssueKey

func IssueKey(is contentcheck.ContentCheckIssue, subject string) string

IssueKey names a warning as it is: its check, element and words (and the subject, for subject checks). English words, whatever the reader's language.

func NormalizeTag

func NormalizeTag(raw string) (string, bool)

NormalizeTag lower-cases and trims a tag, or reports it invalid.

func PostDraftLabel

func PostDraftLabel(site string) string

PostDraftLabel is the first version's label of a draft made from a WordPress post, in English as it's stored: "created from the post on blog.acme.io". The composer's history reads it in each reader's language.

func PostDraftNote

func PostDraftNote(site string) string

PostDraftNote is the campaign list's note of a draft made from a WordPress post, in English as it's stored: "draft from blog.acme.io".

func Register

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

Register adds the campaigns operations.

func RegisterComposer

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

RegisterComposer adds the composer operations.

func ShortName

func ShortName(name, adapter string) string

ShortName is the badge label of a provider: "Amazon SES" → "SES".

func SyncedDeletedLabel

func SyncedDeletedLabel(name string) string

SyncedDeletedLabel is the version label of unlinking a named synced block that was deleted: "Synced block “Webinar banner” deleted in Brand kit".

func SyncedLabel

func SyncedLabel(kind string) string

SyncedLabel is the version label of a synced block's change ("Footer updated in Brand kit"), in English like other stored labels.

func SyncedNamedLabel

func SyncedNamedLabel(name string) string

SyncedNamedLabel is the version label of a named synced block's change (R4.A3): "Synced block “Webinar banner” updated in Brand kit", like other stored labels.

Types

type AgentContent

type AgentContent struct {
	Subject, Preheader, MJML *string
}

AgentContent is what an agent sets on a draft; nil leaves a field as it is.

type AgentSaved

type AgentSaved struct {
	Version, BeforeVersion     int
	Subject, BeforeSubject     string
	Preheader, BeforePreheader string
	SizeBytes                  int
	ContentHash                string
	// Unchanged is true when the draft already had this content: no
	// version was added.
	Unchanged bool
}

AgentSaved is what an agent's save stored.

type CampaignBulkInput

type CampaignBulkInput struct {
	IDs    []string `json:"ids" minItems:"1" maxItems:"200"`
	Action string   `json:"action" enum:"archive,unarchive,delete,tag,untag"`
	// Tag is the tag for tag and untag.
	Tag string `json:"tag,omitempty" maxLength:"40"`
}

CampaignBulkInput is a bulk action on campaigns (CA-2).

type CampaignBulkResult

type CampaignBulkResult struct {
	Done    int                `json:"done"`
	Skipped []CampaignBulkSkip `json:"skipped"`
}

CampaignBulkResult says what a bulk action did.

type CampaignBulkSkip

type CampaignBulkSkip struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Reason string `json:"reason"`
}

CampaignBulkSkip is a campaign a bulk action left alone, and why.

type CampaignCalendar

type CampaignCalendar struct {
	From  time.Time              `json:"from"`
	To    time.Time              `json:"to"`
	Items []CampaignCalendarItem `json:"items"`
}

CampaignCalendar is the calendar between two times.

type CampaignCalendarItem

type CampaignCalendarItem struct {
	// Kind: scheduled (can be moved), sent (or sending) and digest_issue
	// (an issue still to be prepared).
	Kind       string    `json:"kind" enum:"scheduled,sent,digest_issue"`
	ID         string    `json:"id"`
	Name       string    `json:"name"`
	Channel    string    `json:"channel"`
	Status     string    `json:"status"`
	At         time.Time `json:"at"`
	Recipients *int64    `json:"recipients,omitempty"`
	Sent       int64     `json:"sent"`
	// Local is true for a campaign that goes at a time in each recipient's
	// time zone; LocalTime is that time ("09:00").
	Local     bool   `json:"local,omitempty"`
	LocalTime string `json:"localTime,omitempty"`
	DigestID  string `json:"digestId,omitempty"`
	// CampaignID is the campaign of a digest issue, once there is one.
	CampaignID string `json:"campaignId,omitempty"`
	// Approved: an approval covers a scheduled campaign's time, so moving
	// it means unscheduling and asking again (review 2026-11 CA-10).
	Approved bool `json:"approved,omitempty"`
}

CampaignCalendarItem is one thing on the campaigns calendar (CA-3).

type CampaignDigestRef

type CampaignDigestRef struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// IssueStatus is the issue's: prepared, waiting (for approval), held,
	// draft, sending, sent…
	IssueStatus string     `json:"issueStatus" enum:"collecting,preparing,prepared,waiting,held,draft,sending,sent,skipped,not_sent"`
	Posts       int        `json:"posts"`
	PreparedAt  *time.Time `json:"preparedAt,omitempty"`
	SendAt      *time.Time `json:"sendAt,omitempty"`
	// ApprovalID is the issue's open approval request.
	ApprovalID string `json:"approvalId,omitempty"`
}

CampaignDigestRef is the digest an issue belongs to (internal/digests).

type CampaignFollowUpCounts

type CampaignFollowUpCounts struct {
	Received   int64 `json:"received"`
	NonOpeners int64 `json:"nonOpeners" doc:"No open at all"`
	// MachineOnly opened only through privacy protection (Apple Mail): they
	// count as unknown and are left out of a resend.
	MachineOnly int64      `json:"machineOnly"`
	Clickers    int64      `json:"clickers"`
	SentAt      *time.Time `json:"sentAt,omitempty"`
	// Subject is the original's, for the follow-up's suggested subject.
	Subject string `json:"subject"`
}

CampaignFollowUpCounts says who a follow-up would reach.

type CampaignFollowUpInput

type CampaignFollowUpInput struct {
	Kind    string `json:"kind" enum:"non_openers,clickers"`
	Subject string `json:"subject" minLength:"1" maxLength:"998"`
	// DelayHours after the original went out suggests when to send it
	// (Review & send takes it); 0 leaves the time to Review & send.
	DelayHours int `json:"delayHours,omitempty" minimum:"0" maximum:"720"`
}

CampaignFollowUpInput is a follow-up to make.

type CampaignList

type CampaignList struct {
	Items    []CampaignListItem   `json:"items"`
	Total    int64                `json:"total" doc:"Campaigns matching the filter"`
	Page     int                  `json:"page"`
	PageSize int                  `json:"pageSize"`
	Counts   CampaignStatusCounts `json:"counts"`
}

CampaignList is one page of campaigns.

type CampaignListItem

type CampaignListItem struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// Channel is email, sms, push or whatsapp (design expansion phase 8).
	Channel string `json:"channel" enum:"email,sms,push,whatsapp"`
	// Channel rows: opt-outs and cost of a text campaign; Local is true
	// when it goes at a time in each recipient's time zone.
	OptOuts *int64   `json:"optOuts,omitempty"`
	Cost    *float64 `json:"cost,omitempty"`
	Local   bool     `json:"local,omitempty"`
	// LocalTime is that time ("10:00").
	LocalTime string `json:"localTime,omitempty"`
	Status    string `json:"status" enum:"draft,approval,approved,scheduled,sending,paused,sent,cancelled,failed"`
	// Blocked is true for drafts whose latest Send Readiness run is Blocked.
	Blocked bool `json:"blocked"`
	// Audience is a readable label ("Weekly Digest", "All subscribers"); empty when not set.
	Audience    string     `json:"audience"`
	Recipients  *int64     `json:"recipients,omitempty"`
	CreatedAt   time.Time  `json:"createdAt"`
	UpdatedAt   time.Time  `json:"updatedAt"`
	UpdatedBy   string     `json:"updatedBy"`
	ScheduledAt *time.Time `json:"scheduledAt,omitempty"`
	Timezone    string     `json:"timezone,omitempty"`
	StartedAt   *time.Time `json:"startedAt,omitempty"`
	// Rates in percent, set once the campaign has sent anything.
	Delivered  *float64 `json:"delivered,omitempty"`
	HumanOpens *float64 `json:"humanOpens,omitempty"`
	Clicks     *float64 `json:"clicks,omitempty"`
	// Routes lists the sending providers; empty for a draft without an
	// audience (it will use the Broadcasts route).
	Routes []RouteShare `json:"routes"`
	// Origin is the importer source for history pulled in by migration ("brevo").
	Origin string `json:"origin,omitempty"`
	// Notes are short annotations: "A/B subject, winner B", "auto-paused once, Yahoo deferrals".
	Notes []string `json:"notes"`
	// Readiness of unsent campaigns: verdict and number of warnings or blocks.
	Readiness *ReadinessSummary `json:"readiness,omitempty"`
	// Digest is set for an issue of a recurring digest: the Digest badge
	// links to it, and the issue's status reads in place of the campaign's.
	Digest *CampaignDigestRef `json:"digest,omitempty"`
	// PaidOnly is a campaign for paid members only (Earn): its "Paid only"
	// badge.
	PaidOnly bool `json:"paidOnly"`
	// Subject, Tags, ArchivedAt and DeletedAt (review 2026-11 CA-1, CA-2).
	Subject    string     `json:"subject"`
	Tags       []string   `json:"tags"`
	ArchivedAt *time.Time `json:"archivedAt,omitempty"`
	DeletedAt  *time.Time `json:"deletedAt,omitempty"`
}

CampaignListItem is one row of the campaigns list.

type CampaignPath

type CampaignPath struct {
	api.WorkspaceInput
	CampaignID string `path:"campaignId" format:"uuid"`
}

CampaignPath is the {workspace}/{campaignId} part of composer operations.

type CampaignStatusCounts

type CampaignStatusCounts struct {
	All       int64 `json:"all"`
	Drafts    int64 `json:"drafts"`
	Scheduled int64 `json:"scheduled"`
	Sending   int64 `json:"sending"`
	Sent      int64 `json:"sent"`
	// PaidOnly counts the campaigns for paid members only (Earn).
	PaidOnly int64 `json:"paidOnly"`
	// Archived and Deleted are the tabs of review 2026-11 CA-1 (deleted:
	// restorable, the last 30 days).
	Archived int64 `json:"archived"`
	Deleted  int64 `json:"deleted"`
}

CampaignStatusCounts feeds the All / Drafts / Scheduled / Sending / Sent tabs, counted within the list's filters (review 2026-11 CA-12).

type CampaignSummary

type CampaignSummary struct {
	Days        int            `json:"days"`
	Campaigns   int64          `json:"campaigns"`
	Sent        int64          `json:"sent"`
	Delivered   *float64       `json:"delivered,omitempty"`
	Bounces     *float64       `json:"bounces,omitempty"`
	Complaints  *float64       `json:"complaints,omitempty"`
	HumanOpens  *float64       `json:"humanOpens,omitempty"`
	Clicks      *float64       `json:"clicks,omitempty"`
	ClickToOpen *float64       `json:"clickToOpen,omitempty"`
	Cost        float64        `json:"cost" doc:"Dollars"`
	CostBy      []ProviderCost `json:"costBy"`
}

CampaignSummary is the KPI row above the list (last 30 days).

type CampaignTags

type CampaignTags struct {
	Tags []string `json:"tags"`
}

CampaignTags lists the workspace's campaign tags.

type ChangeHook

type ChangeHook func(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID)

ChangeHook is told which campaign changed. The save already committed, so a hook handles its own errors.

type ChannelRows

type ChannelRows interface {
	FillChannelRows(ctx context.Context, ws *store.Workspace, items []CampaignListItem)
}

ChannelRows fills in the list's rows of one channel's campaigns (internal/texting for SMS).

type ComposerABTest

type ComposerABTest struct {
	Kind        string              `json:"kind" enum:"subject,content,send_time"`
	Variants    []ComposerABVariant `json:"variants" minItems:"2" maxItems:"3"`
	TestPercent int                 `json:"testPercent" minimum:"5" maximum:"50" doc:"Share of the audience in the test"`
	Metric      string              `json:"metric" enum:"human_opens,clicks,manual"`
	// DurationHours is how long the test runs before the winner is sent.
	DurationHours int `json:"durationHours" minimum:"1" maximum:"72"`
	// BestTime sends each recipient at their usual open time (send-time tests).
	BestTime bool   `json:"bestTime,omitempty"`
	Winner   string `json:"winner,omitempty"`
	// The decision rule (review AN-1): a variant wins only when every
	// variant reached MinSample recipients (500 when unset) and its lead is
	// significant at Confidence (0.95 when unset); otherwise the rest get
	// NoWinner: "default", the first variant (A).
	MinSample  int     `` /* 136-byte string literal not displayed */
	Confidence float64 `json:"confidence,omitempty" minimum:"0" maximum:"0.999" doc:"How sure the test must be (default 0.95)"`
	NoWinner   string  `json:"noWinner,omitempty" enum:"default" doc:"What the rest get without a clear winner: default, the first variant"`
}

ComposerABTest compares variants on a sample, then sends the winner to the rest.

type ComposerABVariant

type ComposerABVariant struct {
	Key       string `json:"key" enum:"A,B,C" doc:"Variant A is the campaign itself"`
	Subject   string `json:"subject,omitempty" maxLength:"998"`
	Preheader string `json:"preheader,omitempty" maxLength:"500"`
	// MJML and HTML are set for content tests (variants B and C).
	MJML string `json:"mjml,omitempty" maxLength:"2000000"`
	HTML string `json:"html,omitempty" maxLength:"2000000"`
	// SendTime is the local send time for send-time tests ("14:00").
	SendTime string `json:"sendTime,omitempty" pattern:"^([01]\\d|2[0-3]):[0-5]\\d$"`
}

ComposerABVariant is one variant of an A/B test.

type ComposerAccess

type ComposerAccess struct {
	// Editable is false once a campaign started sending.
	Editable       bool   `json:"editable"`
	ReadOnlyReason string `json:"readOnlyReason,omitempty"`
	CanEdit        bool   `json:"canEdit"`
	// CanSend is campaigns:send. Without it "Review & send" becomes "Request approval".
	CanSend     bool     `json:"canSend"`
	SendHelpers []string `json:"sendHelpers" doc:"Members who hold campaigns:send"`
	// EditHelpers are members who hold campaigns:edit, named to people who
	// can't edit (the Accessibility panel's read-only note).
	EditHelpers []string `json:"editHelpers,omitempty" doc:"Members who hold campaigns:edit (when the caller can't edit)"`
	// CanManageRouting is providers:manage; others see the route read-only.
	CanManageRouting bool `json:"canManageRouting"`
	// CanSendTestToOthers lets test emails go to other addresses (campaigns:send).
	CanSendTestToOthers bool `json:"canSendTestToOthers"`
	CanEditTemplates    bool `json:"canEditTemplates"`
	CanViewContacts     bool `json:"canViewContacts"`
}

ComposerAccess tells the composer what the caller may do.

type ComposerApproval

type ComposerApproval struct {
	ID     string `json:"id"`
	Status string `json:"status" enum:"pending,approved"`
	// RequestedBy is who asked; ApprovedBy who approved, in order.
	RequestedBy string     `json:"requestedBy"`
	RequestedAt time.Time  `json:"requestedAt"`
	ApprovedBy  []string   `json:"approvedBy"`
	DecidedAt   *time.Time `json:"decidedAt,omitempty"`
	// Version is the campaign version the request covers.
	Version int `json:"version"`
}

ComposerApproval is a campaign's pending or approved request, as the composer tells someone about to edit it (ComposerStates: "Edit an approved campaign?").

type ComposerAudience

type ComposerAudience struct {
	Lists           []string `json:"lists"`
	Segments        []string `json:"segments"`
	ExcludeLists    []string `json:"excludeLists"`
	ExcludeSegments []string `json:"excludeSegments"`
	// Paid is "paid" for paid members only, "free" for free subscribers
	// only; empty for everyone. PaidTier is the lowest tier of paid
	// members ("Insider and above"); empty for any paid tier.
	Paid     string `json:"paid,omitempty" enum:"paid,free,"`
	PaidTier string `json:"paidTier,omitempty"`
	// Cadence (review 2026-11 CA-6, D1): a regular issue reaches readers
	// who get every issue; an announcement reaches everyone on its lists
	// whatever rhythm they chose. Empty is regular.
	Cadence string `json:"cadence,omitempty" enum:"regular,announcement,"`
}

ComposerAudience says who receives a campaign: lists and segments, minus excluded lists and segments, and who on them (Earn: everyone, paid members only at a tier and above, or free subscribers only).

type ComposerAudienceCount

type ComposerAudienceCount struct {
	Count int64 `json:"count"`
	// Approximate is true when segments are involved: their last cached
	// count is used, so overlaps may be counted twice until Send Readiness
	// computes the final number.
	Approximate bool `json:"approximate"`
	// ChoseRhythm counts the lists' subscribers who chose a weekly or
	// monthly rhythm on the preference center: a regular issue leaves them
	// out, an announcement reaches them (review 2026-11 CA-6).
	ChoseRhythm int64 `json:"choseRhythm"`
}

ComposerAudienceCount is the live count of an audience definition.

type ComposerAudienceInput

type ComposerAudienceInput struct {
	Lists           []string `json:"lists,omitempty" maxItems:"100"`
	Segments        []string `json:"segments,omitempty" maxItems:"100"`
	ExcludeLists    []string `json:"excludeLists,omitempty" maxItems:"100"`
	ExcludeSegments []string `json:"excludeSegments,omitempty" maxItems:"100"`
	Paid            string   `` /* 128-byte string literal not displayed */
	PaidTier        string   `json:"paidTier,omitempty" doc:"With paid: the lowest tier (the tier and above); empty for any paid tier"`
	Cadence         string   `` /* 158-byte string literal not displayed */
}

ComposerAudienceInput is an audience in requests (every part optional).

type ComposerAudienceOption

type ComposerAudienceOption struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Count *int64 `json:"count,omitempty"`
}

ComposerAudienceOption is a list or segment with its size.

type ComposerCampaign

type ComposerCampaign struct {
	ID            string                  `json:"id"`
	Name          string                  `json:"name"`
	Status        string                  `json:"status" enum:"draft,approval,approved,scheduled,sending,paused,sent,cancelled,failed"`
	Subject       string                  `json:"subject"`
	Preheader     string                  `json:"preheader"`
	Sender        *ComposerSenderRef      `json:"sender,omitempty"`
	ReplyTo       string                  `json:"replyTo"`
	Audience      ComposerAudience        `json:"audience"`
	AudienceLabel string                  `json:"audienceLabel"`
	AudienceCount *int64                  `json:"audienceCount,omitempty"`
	EditorMode    string                  `json:"editorMode" enum:"visual,mjml,html"`
	MJML          string                  `json:"mjml"`
	HTML          string                  `json:"html"`
	PlainText     string                  `json:"plainText"`
	Version       int                     `json:"version"`
	VersionCount  int                     `json:"versionCount"`
	ContentHash   string                  `json:"contentHash"`
	ABTest        *ComposerABTest         `json:"abTest,omitempty"`
	Settings      ComposerContentSettings `json:"settings"`
	ScheduledAt   *time.Time              `json:"scheduledAt,omitempty"`
	CreatedAt     time.Time               `json:"createdAt"`
	UpdatedAt     time.Time               `json:"updatedAt"`
	UpdatedBy     string                  `json:"updatedBy"`
	AutosavedAt   *time.Time              `json:"autosavedAt,omitempty"`
	Route         ComposerRoute           `json:"route"`
	Readiness     *ReadinessSummary       `json:"readiness,omitempty"`
	Access        ComposerAccess          `json:"access"`
	// Language is the language of the content returned: the source's, or
	// the language version asked for with ?language=. SourceLanguage is the
	// language the campaign is written in. Both are empty without content
	// languages.
	Language       string `json:"language"`
	SourceLanguage string `json:"sourceLanguage"`
	// DigestID is set for a recurring digest's template (DigestRole
	// "template"), its next issue ("next") and its issues ("issue"): the
	// composer opens in digest mode (internal/digests).
	DigestID   string `json:"digestId,omitempty"`
	DigestRole string `json:"digestRole,omitempty" enum:"template,next,issue,"`
	// Approval is the campaign's pending or approved request: editing
	// cancels it, so the composer asks first.
	Approval *ComposerApproval `json:"approval,omitempty"`
}

ComposerCampaign is everything the composer loads.

type ComposerChecks

type ComposerChecks struct {
	contentcheck.ContentCheckReport
	// FooterRemovedAt is when the version without a footer was saved, if the
	// footer existed in an earlier version.
	FooterRemovedAt *time.Time `json:"footerRemovedAt,omitempty"`
	// Lint lists MJML layout warnings (image wider than its column…).
	Lint []mjml.MJMLProblem `json:"lint"`
	// Variants are what checking each A/B variant (its subject and
	// preheader, or its content) finds beyond variant A's issues above.
	Variants []ComposerVariantChecks `json:"variants"`
	// IssueKeys name each of issues, to dismiss a warning (CO-14).
	IssueKeys []string `json:"issueKeys"`
	// Dismissed are the warnings someone dismissed, with why.
	Dismissed []ComposerDismissedIssue `json:"dismissed"`
}

ComposerChecks is a content report plus what the composer shows around it.

type ComposerChecksRequest

type ComposerChecksRequest struct {
	Subject    string `json:"subject,omitempty" maxLength:"998"`
	Preheader  string `json:"preheader,omitempty" maxLength:"500"`
	MJML       string `json:"mjml,omitempty" maxLength:"2000000"`
	HTML       string `json:"html,omitempty" maxLength:"2500000"`
	ProbeLinks bool   `json:"probeLinks,omitempty" doc:"Also request every link (slower; Send Readiness does it)"`
	// Language is the language version checked: subject heuristics look for
	// English phrases only in English.
	Language string `json:"language,omitempty" maxLength:"16"`
	// ABTest is the A/B test as the composer has it, unsaved edits
	// included: variants B and C are checked too (ComposerChecks.Variants).
	ABTest *ComposerABTest `json:"abTest,omitempty"`
}

ComposerChecksRequest is content to check (unsaved edits included).

type ComposerComment

type ComposerComment struct {
	ID   string `json:"id"`
	Body string `json:"body"`
	// Author is the member's name, or the name a reviewer gave.
	Author   string `json:"author"`
	AuthorID string `json:"authorId,omitempty"`
	// AuthorColor is the member's avatar colour (empty for a reviewer).
	AuthorColor string `json:"authorColor,omitempty"`
	// Reviewer is true for a comment through a review link (no account).
	Reviewer  bool      `json:"reviewer"`
	Version   int       `json:"version" doc:"The campaign version it was written on"`
	Mentions  []string  `json:"mentions" doc:"Members it notified (user ids)"`
	CreatedAt time.Time `json:"createdAt"`
}

ComposerComment is one comment of a thread.

type ComposerCommentInput

type ComposerCommentInput struct {
	Body string `json:"body" minLength:"1" maxLength:"4000"`
	// ThreadID replies to that thread; Anchor and AnchorLabel are then ignored.
	ThreadID    string `json:"threadId,omitempty" format:"uuid"`
	Anchor      string `json:"anchor,omitempty" maxLength:"40" doc:"The block's rc-comment id; empty for the whole email"`
	AnchorLabel string `json:"anchorLabel,omitempty" maxLength:"200"`
	// Mentions are the members to notify (user ids): they get a
	// notification, by email too unless they turned that off.
	Mentions []string `json:"mentions,omitempty" maxItems:"20"`
}

ComposerCommentInput starts a thread or replies to one.

type ComposerCompileRequest

type ComposerCompileRequest struct {
	MJML string `json:"mjml" minLength:"1" maxLength:"2000000"`
}

ComposerCompileRequest is MJML to compile on the server.

type ComposerCompiled

type ComposerCompiled struct {
	HTML       string             `json:"html"`
	Errors     []mjml.MJMLProblem `json:"errors"`
	Warnings   []mjml.MJMLProblem `json:"warnings"`
	SizeBytes  int                `json:"sizeBytes"`
	DurationMs int64              `json:"durationMs"`
}

ComposerCompiled is the server-side compile result (gomjml, MJML 4.15).

type ComposerContentSettings

type ComposerContentSettings struct {
	// Minify shrinks the HTML (whitespace, inline CSS) to stay under Gmail's clipping limit.
	Minify bool `json:"minify"`
	// UTM is the campaign's own "Add UTM tags": its links get utm_source,
	// utm_medium and utm_campaign when it sends. Omitted, the workspace's
	// setting applies (Settings › Senders).
	UTM *bool `json:"utm,omitempty" doc:"Add UTM tags to the campaign's links; omit to follow the workspace's setting"`
}

ComposerContentSettings are composer options applied to the stored HTML.

func (ComposerContentSettings) UTMOn

func (s ComposerContentSettings) UTMOn(workspace bool) bool

UTMOn reports whether the campaign's links get UTM tags: its own choice, else the workspace's "Add UTM tags to links" (workspace).

type ComposerContext

type ComposerContext struct {
	Senders         []ComposerSenderOption        `json:"senders"`
	DefaultSenderID string                        `json:"defaultSenderId,omitempty"`
	Lists           []ComposerAudienceOption      `json:"lists"`
	Segments        []ComposerAudienceOption      `json:"segments"`
	Tokens          []liquid.PersonalizationToken `json:"tokens"`
	Members         []ComposerTestRecipient       `json:"members"`
	BroadcastRoute  ComposerRoute                 `json:"broadcastRoute"`
	// PostalAddress is the workspace's address for footers, if set.
	PostalAddress string `json:"postalAddress"`
	// PublicURL is where images and links point once an email leaves ReputeCast.
	PublicURL     string   `json:"publicUrl"`
	SenderDomains []string `json:"senderDomains"`
}

ComposerContext is the workspace data the composer needs once.

type ComposerCreateCampaign

type ComposerCreateCampaign struct {
	Name           string `json:"name,omitempty" maxLength:"200"`
	TemplateID     string `json:"templateId,omitempty" maxLength:"64" doc:"Start from a template (starter:<key> or a saved template id)"`
	FromCampaignID string `json:"fromCampaignId,omitempty" format:"uuid" doc:"Start from a copy of another campaign's content"`
}

ComposerCreateCampaign starts a draft, blank or from a template or another campaign.

type ComposerDismissInput

type ComposerDismissInput struct {
	// Key is the warning's key from the checks (issueKeys).
	Key     string `json:"key" minLength:"1" maxLength:"64" pattern:"^[a-f0-9]+$"`
	CheckID string `json:"checkId" minLength:"1" maxLength:"80"`
	Title   string `json:"title,omitempty" maxLength:"300"`
	Reason  string `json:"reason" enum:"decorative,size,subject,wrong,other"`
	Note    string `json:"note,omitempty" maxLength:"500"`
}

ComposerDismissInput dismisses a warning of the last checks.

type ComposerDismissal

type ComposerDismissal struct {
	ID      string `json:"id"`
	Key     string `json:"key"`
	CheckID string `json:"checkId"`
	Reason  string `json:"reason" enum:"decorative,size,subject,wrong,other"`
	// ReasonText is the reason in the reader's language ("the image is decorative").
	ReasonText string    `json:"reasonText"`
	Note       string    `json:"note"`
	By         string    `json:"by"`
	At         time.Time `json:"at"`
}

ComposerDismissal is a dismissed warning.

type ComposerDismissedIssue

type ComposerDismissedIssue struct {
	// Index is the issue's position in issues.
	Index     int               `json:"index"`
	Dismissal ComposerDismissal `json:"dismissal"`
}

ComposerDismissedIssue marks one of the checks' issues as dismissed.

type ComposerMember

type ComposerMember struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Role  string `json:"role"`
	Color string `json:"color" doc:"Avatar colour"`
}

ComposerMember is someone who can be @mentioned.

type ComposerMemberList

type ComposerMemberList struct {
	Items []ComposerMember `json:"items"`
}

ComposerMemberList is who can be @mentioned in a campaign's comments.

type ComposerMerged

type ComposerMerged struct {
	With     string               `json:"with" doc:"Who saved the newer version"`
	Version  int                  `json:"version" doc:"Their version"`
	Sections []mjml.MergedSection `json:"sections" doc:"Their sections, at their positions in the email"`
	// Head is their mj-head (styles, title, preview) when they changed it.
	Head      string  `json:"head,omitempty"`
	Subject   *string `json:"subject,omitempty"`
	Preheader *string `json:"preheader,omitempty"`
}

ComposerMerged is what a merged save took from the newer version.

type ComposerNameVersion

type ComposerNameVersion struct {
	Name string `json:"name" maxLength:"120" doc:"The version's name; empty removes it"`
}

ComposerNameVersion names a version ("" removes its name).

type ComposerPresence

type ComposerPresence struct {
	Others []ComposerPresent `json:"others"`
}

ComposerPresence is who else has the campaign open.

type ComposerPresenceInput

type ComposerPresenceInput struct {
	// Editing is true while the caller is changing the email (typed or
	// changed something in the last minute).
	Editing bool `json:"editing,omitempty"`
}

ComposerPresenceInput says the caller has the campaign open.

type ComposerPresent

type ComposerPresent struct {
	UserID  string    `json:"userId"`
	Name    string    `json:"name"`
	Color   string    `json:"color" doc:"Avatar colour"`
	Editing bool      `json:"editing"`
	SeenAt  time.Time `json:"seenAt"`
}

ComposerPresent is someone else with the campaign open.

type ComposerPreview

type ComposerPreview struct {
	Subject   string                  `json:"subject"`
	Preheader string                  `json:"preheader"`
	HTML      string                  `json:"html"`
	Text      string                  `json:"text"`
	FromName  string                  `json:"fromName"`
	FromEmail string                  `json:"fromEmail"`
	Contact   *ComposerPreviewContact `json:"contact,omitempty"`
	Tokens    []ComposerTokenValue    `json:"tokens"`
	// MissingFirstName counts audience contacts with no first name (they see the fallback).
	MissingFirstName *int64 `json:"missingFirstName,omitempty"`
	// Counted is how many audience contacts the tokens' AudienceMissing
	// counts were made over: the campaign's lists minus excluded lists and
	// suppressions. CountedListsOnly is true when the audience also has
	// segments, which aren't counted. Without lists, or without
	// subscribers:view, nothing is counted.
	Counted          *int64                 `json:"counted,omitempty"`
	CountedListsOnly bool                   `json:"countedListsOnly,omitempty"`
	Problems         []liquid.LiquidProblem `json:"problems"`
	RenderedAt       time.Time              `json:"renderedAt"`
	// Language is the language version shown, and LanguageReason why when
	// it was picked for the contact (match, no_language, not_offered,
	// missing, draft, held). Empty without content languages.
	Language       string `json:"language"`
	LanguageReason string `json:"languageReason"`
}

ComposerPreview is the rendered email for one recipient.

type ComposerPreviewContact

type ComposerPreviewContact struct {
	ID    string `json:"id,omitempty"`
	Name  string `json:"name"`
	Email string `json:"email"`
	// FirstName and LastName are the contact's own fields, as a send fills
	// them in ({{ first_name }}, {{ last_name }}); Name only displays them.
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	// Label describes the choice ("first_name set", "fallback "there"").
	Label string `json:"label"`
	// Language is the contact's language code ("es-MX"), empty when unset.
	Language string `json:"language"`
}

ComposerPreviewContact is who the preview is personalized for.

type ComposerPreviewContactList

type ComposerPreviewContactList struct {
	Items []ComposerPreviewContact `json:"items"`
}

ComposerPreviewContactList is who the preview can be personalized for.

type ComposerPreviewRequest

type ComposerPreviewRequest struct {
	ContactID string  `json:"contactId,omitempty" format:"uuid"`
	Sample    string  `json:"sample,omitempty" enum:"contact,no_first_name,random" default:"contact"`
	Variant   string  `json:"variant,omitempty" enum:"A,B,C"`
	Subject   *string `json:"subject,omitempty" maxLength:"998"`
	Preheader *string `json:"preheader,omitempty" maxLength:"500"`
	HTML      *string `json:"html,omitempty" maxLength:"2500000"`
	// Language previews a language version. Empty: the source, or, when
	// previewing as a contact, the version that contact gets.
	Language string `json:"language,omitempty" maxLength:"16"`
	// Editing is the version the subject, preheader and HTML above belong
	// to (the one the composer has open; empty is the source). Previewing as
	// a contact who gets another version shows that version as saved.
	Editing string `json:"editing,omitempty" maxLength:"16"`
	// contains filtered or unexported fields
}

ComposerPreviewRequest asks for the email as one recipient sees it. Subject, preheader and HTML may carry unsaved edits.

type ComposerResolveInput

type ComposerResolveInput struct {
	Resolved bool `json:"resolved"`
}

ComposerResolveInput resolves a thread or opens it again.

type ComposerRestoreVersion

type ComposerRestoreVersion struct {
	BaseVersion int `json:"baseVersion" minimum:"1"`
}

ComposerRestoreVersion makes an old version current again, as a new version.

type ComposerReviewLink struct {
	ID        string    `json:"id"`
	URL       string    `json:"url" doc:"Shown to the workspace's members only"`
	Version   int       `json:"version" doc:"The version reviewers see"`
	CreatedBy string    `json:"createdBy"`
	CreatedAt time.Time `json:"createdAt"`
	ExpiresAt time.Time `json:"expiresAt"`
}

ComposerReviewLink is a link members share with reviewers.

type ComposerReviewLinkList struct {
	Items []ComposerReviewLink `json:"items"`
}

ComposerReviewLinkList is a campaign's working review links, newest first.

type ComposerRoute

type ComposerRoute struct {
	Source string       `json:"source" enum:"campaign,rule,none"`
	Shares []RouteShare `json:"shares"`
}

ComposerRoute is the sending route of a campaign: its planned split, or the Broadcasts rule when it has none yet.

type ComposerSaveContent

type ComposerSaveContent struct {
	// BaseVersion is the version the editor started from. Saving on top of
	// someone else's newer version fails with 409 unless Force is set.
	BaseVersion int    `json:"baseVersion" minimum:"1"`
	Subject     string `json:"subject,omitempty" maxLength:"998"`
	Preheader   string `json:"preheader,omitempty" maxLength:"500"`
	MJML        string `json:"mjml,omitempty" maxLength:"2000000"`
	// HTML compiled by the composer (mjml-browser). Empty: the server
	// compiles the MJML with gomjml.
	HTML   string          `json:"html,omitempty" maxLength:"2500000"`
	ABTest *ComposerABTest `json:"abTest,omitempty"`
	// Label says what changed ("2-column section padding").
	Label  string `json:"label,omitempty" maxLength:"200"`
	Source string `json:"source,omitempty" enum:"autosave,manual,import,template,recovered" default:"autosave"`
	// Force saves on top of a newer version ("Keep mine").
	Force bool `json:"force,omitempty"`
	// Stash keeps this content in the version history without making it
	// current ("Load theirs" after a conflict): it is saved as a version,
	// then the current content is saved on top of it, unchanged.
	Stash bool `json:"stash,omitempty"`
	// CancelApproval says the person knows saving cancels the campaign's
	// pending or approved request; without it such a save through the API
	// fails with 409 approval_would_cancel (CO-7).
	CancelApproval bool `json:"cancelApproval,omitempty"`
	// contains filtered or unexported fields
}

ComposerSaveContent is one save of the composer: subject, preheader, MJML and the HTML the browser compiled from it, and the A/B variants.

type ComposerSavedContent

type ComposerSavedContent struct {
	Version     int       `json:"version"`
	SavedAt     time.Time `json:"savedAt"`
	ContentHash string    `json:"contentHash"`
	SizeBytes   int       `json:"sizeBytes"`
	PlainText   string    `json:"plainText"`
	// HTML is what was stored (minified when the campaign asks for it).
	HTML string `json:"html"`
	// Unchanged is true when the content was already the current version's:
	// nothing new was stored and Version is that version.
	Unchanged bool `json:"unchanged,omitempty"`
	// StashedVersion is the version that keeps the stashed content (Stash).
	StashedVersion int `json:"stashedVersion,omitempty"`
	// Recompiled says what the HTML sent got wrong when it didn't show or do
	// what the MJML says (links, images, text, conditional markers): the
	// server stored its own compile of the MJML instead.
	Recompiled string `json:"recompiled,omitempty"`
	// Merged is set when someone saved a newer version in the meantime and
	// the two edits changed different sections: both were kept (CO-10).
	// The composer puts their sections in; the rest is yours.
	Merged *ComposerMerged `json:"merged,omitempty"`
}

ComposerSavedContent is the result of a save.

type ComposerSenderOption

type ComposerSenderOption struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Email    string `json:"email"`
	Domain   string `json:"domain"`
	Verified bool   `json:"verified"`
}

ComposerSenderOption is a sender the campaign can come from.

type ComposerSenderRef

type ComposerSenderRef struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

ComposerSenderRef is the "From" identity.

type ComposerTestRecipient

type ComposerTestRecipient struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

ComposerTestRecipient is a workspace member offered for test emails.

type ComposerTestSend

type ComposerTestSend struct {
	To        []string `json:"to" minItems:"1" maxItems:"10"`
	Variant   string   `json:"variant,omitempty" enum:"A,B,C"`
	ContactID string   `json:"contactId,omitempty" format:"uuid" doc:"Personalize as this contact"`
	// Sample no_first_name personalizes the test as Preview's reader
	// without a first name (the fallbacks show). Without it or a contact,
	// the test is personalized as the audience's first contact.
	Sample string `json:"sample,omitempty" enum:"contact,no_first_name" doc:"Personalize as Preview's reader without a first name"`
	// Language sends one language version (the source when empty);
	// EachLanguage sends one email per language that would be sent.
	Language     string `json:"language,omitempty" maxLength:"16"`
	EachLanguage bool   `json:"eachLanguage,omitempty"`
}

ComposerTestSend sends the saved content to a few addresses.

type ComposerTestSendResult

type ComposerTestSendResult struct {
	Sent     []string `json:"sent"`
	Provider string   `json:"provider"`
	// Languages are the versions sent to each address.
	Languages []string `json:"languages"`
}

ComposerTestSendResult says where the test went.

type ComposerThread

type ComposerThread struct {
	ID string `json:"id"`
	// Anchor is the rc-comment id of the block it's on; empty for the
	// whole email. AnchorLabel says what the block was when it started
	// ("the button “Read the docs”").
	Anchor      string            `json:"anchor"`
	AnchorLabel string            `json:"anchorLabel"`
	Comments    []ComposerComment `json:"comments"`
	ResolvedAt  *time.Time        `json:"resolvedAt,omitempty"`
	ResolvedBy  string            `json:"resolvedBy,omitempty"`
}

ComposerThread is a comment and its replies.

type ComposerThreadList

type ComposerThreadList struct {
	Threads  []ComposerThread `json:"threads"`
	Open     int              `json:"open"`
	Resolved int              `json:"resolved"`
}

ComposerThreadList is a campaign's comments: open threads, then resolved ones, each oldest first.

type ComposerTokenValue

type ComposerTokenValue struct {
	Token string `json:"token" example:"{{ first_name | default: \"there\" }}"`
	Key   string `json:"key"`
	Value string `json:"value"`
	// Missing is true when the contact previewed has no value for the
	// field: the fallback prints (FallbackUsed), or nothing when it has none.
	Missing      bool `json:"missing"`
	FallbackUsed bool `json:"fallbackUsed"`
	PerRecipient bool `json:"perRecipient" doc:"A link filled in per recipient at send time"`
	// Unknown is true when the variable isn't a contact field or anything
	// ReputeCast fills in: it prints nothing for everyone, fallback or not.
	// Suggestion is the field it most likely meant ("first_name").
	Unknown    bool   `json:"unknown"`
	Suggestion string `json:"suggestion,omitempty"`
	// AudienceMissing counts the audience contacts with no value for this
	// field (contact and custom fields; see ComposerPreview.Counted).
	AudienceMissing *int64 `json:"audienceMissing,omitempty"`
}

ComposerTokenValue is what one token printed.

type ComposerUpdateCampaign

type ComposerUpdateCampaign struct {
	Name     *string                  `json:"name,omitempty" minLength:"1" maxLength:"200"`
	SenderID *string                  `json:"senderId,omitempty" doc:"A sender id, or empty to clear"`
	ReplyTo  *string                  `json:"replyTo,omitempty" maxLength:"254"`
	Audience *ComposerAudienceInput   `json:"audience,omitempty"`
	Settings *ComposerContentSettings `json:"settings,omitempty"`
}

ComposerUpdateCampaign changes what isn't versioned content: name, sender, reply-to, audience and content settings. Omitted fields stay.

type ComposerVariantChecks

type ComposerVariantChecks struct {
	Key      string                           `json:"key" enum:"B,C"`
	Blocks   int                              `json:"blocks"`
	Warnings int                              `json:"warnings"`
	Issues   []contentcheck.ContentCheckIssue `json:"issues"`
}

ComposerVariantChecks is what one A/B variant's check finds that variant A's doesn't (a subject that trips a spam heuristic, a broken link in its content, no subject at all).

type ComposerVersion

type ComposerVersion struct {
	Version   int       `json:"version"`
	SavedAt   time.Time `json:"savedAt"`
	SavedBy   string    `json:"savedBy"`
	Label     string    `json:"label"`
	Source    string    `json:"source" enum:"create,autosave,manual,restore,template,import,duplicate,api,conflict,merge,recovered,synced"`
	SizeBytes int       `json:"sizeBytes"`
	Current   bool      `json:"current"`
	// Name is what a person called the version ("Sent to legal"); named
	// versions are never pruned and can be listed on their own.
	Name string `json:"name"`
}

ComposerVersion is one entry of the version history.

type ComposerVersionDetail

type ComposerVersionDetail struct {
	ComposerVersion
	Subject   string          `json:"subject"`
	Preheader string          `json:"preheader"`
	MJML      string          `json:"mjml"`
	HTML      string          `json:"html"`
	ABTest    *ComposerABTest `json:"abTest,omitempty"`
	// Sections are the labels of the sections that differ from the version before.
	Sections []string `json:"sections"`
}

ComposerVersionDetail is a version with its content (compare, restore).

type ComposerVersionList

type ComposerVersionList struct {
	Items []ComposerVersion `json:"items"`
	// Total counts every version kept; Named the named ones.
	Total int `json:"total"`
	Named int `json:"named"`
	// NextBefore asks for the next (older) page; absent on the last page.
	NextBefore *int `json:"nextBefore,omitempty"`
}

ComposerVersionList is one page of the version history, newest first.

type Extras

type Extras interface {
	// TestLinks are the poll and survey links of a test email to one
	// address: its answers are that address's test answers, never counted.
	TestLinks(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, email string) (map[string]string, error)
	// TestVersion is the email a contact gets ("" contact: every block).
	TestVersion(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, contactID, html string) string
}

Extras fill in a test email's poll links and cut it to one contact's version of conditional content.

type ListParams

type ListParams struct {
	Status string
	Query  string
	// Channel filters by channel; empty is every channel.
	Channel  string
	PaidOnly bool
	Page     int
	PageSize int
	// From and To bound when a campaign went or goes out; Sender, List
	// (one of its audience's lists) and Tag narrow the list (review
	// 2026-11 CA-2).
	From, To *time.Time
	Sender   *uuid.UUID
	List     string
	Tag      string
	// ItemsOnly skips the totals and the tab counts (Overview's "Recent",
	// review 2026-11 CA-7).
	ItemsOnly bool
}

ListParams filters the list.

type MoreChecks

type MoreChecks func(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, mjml string) []contentcheck.ContentCheckIssue

MoreChecks are other domains' findings about an email's content, for the composer's checks.

type ProviderCost

type ProviderCost struct {
	Provider string  `json:"provider"`
	Short    string  `json:"short"`
	Cost     float64 `json:"cost"`
}

ProviderCost is one provider's cost in the period.

type ReadinessSummary

type ReadinessSummary struct {
	Verdict string `json:"verdict" enum:"ready,warnings,blocked"`
	// Issues are the blocking issues of a blocked campaign, otherwise its
	// warnings.
	Issues int64 `json:"issues"`
}

ReadinessSummary is the latest Send Readiness verdict.

type ReviewCommentInput

type ReviewCommentInput struct {
	Name string `json:"name" minLength:"1" maxLength:"80" doc:"How the reviewer signs their comment"`
	Body string `json:"body" minLength:"1" maxLength:"4000"`
	// ThreadID replies to a thread written through the same link.
	ThreadID string `json:"threadId,omitempty" format:"uuid"`
}

ReviewCommentInput is a reviewer's comment.

type ReviewPage

type ReviewPage struct {
	Workspace string `json:"workspace"`
	Campaign  string `json:"campaign"`
	Version   int    `json:"version"`
	Subject   string `json:"subject"`
	Preheader string `json:"preheader"`
	HTML      string `json:"html"`
	// Sample is the sample reader the email is personalized for.
	Sample    string           `json:"sample"`
	FromName  string           `json:"fromName"`
	ExpiresAt time.Time        `json:"expiresAt"`
	Threads   []ComposerThread `json:"threads"`
}

ReviewPage is what a reviewer sees: the email of one version and the comments written through the link. Nothing about the audience, settings or other campaigns.

type ReviewToken

type ReviewToken struct {
	Token string `path:"token" maxLength:"64" doc:"The token from the review link"`
}

ReviewToken is a review link's {token}.

type RouteShare

type RouteShare struct {
	ProviderID string `json:"providerId"`
	Provider   string `json:"provider" example:"Amazon SES"`
	// Short is the label used in badges ("SES", "Postal").
	Short   string `json:"short" example:"SES"`
	Adapter string `json:"adapter" example:"ses"`
	// Percent of the planned audience routed to this provider (unsent campaigns).
	Percent float64 `json:"percent"`
	// Planned recipients and, once sending started, how many were sent.
	Planned int64 `json:"planned"`
	Sent    int64 `json:"sent"`
}

RouteShare is one sending provider's part of a campaign.

type Service

type Service struct {
	Pool  *pgxpool.Pool
	Q     *store.Queries
	Audit *audit.Logger
	Now   func() time.Time
	// Templates resolves templates when a draft starts from one.
	Templates *templates.Service
	// Mail sends test emails through the System route (App.Mail, read at call time).
	Mail func() mailer.Sender
	// URLs builds public links (unsubscribe, preferences, view online).
	URLs publicurl.Builder
	// Checker runs the content checks (blocklist and link probing plug in here).
	Checker *contentcheck.Checker
	// AfterChange runs once a save of the content, audience, sender or
	// settings committed (the approvals domain re-checks open approvals).
	AfterChange ChangeHook
	// Translations handles language versions (?language= on the content
	// endpoints); nil without content languages.
	Translations Translations
	// Extras fill in test emails' poll links and cut them to a contact's
	// version of conditional content (conditional.go); nil leaves them.
	Extras Extras
	// More adds other domains' findings to the composer's checks (the
	// Sponsor block's creative, internal/sponsors); nil leaves them out.
	More MoreChecks
	// Channels fill in the rows of campaigns on other channels (SMS, and
	// later push and WhatsApp): their routes, results and readiness. Nil
	// leaves those rows as stored.
	Channels ChannelRows
	// Recipients add the per-reader variables of blocks (Grow's Referral
	// and Recommendations blocks) to previews and test sends; nil adds none.
	Recipients func() []liquid.RecipientData
	// Box seals review links' tokens so members can copy a link again
	// (review.go); review links need it.
	Box *secrets.Box
}

Service holds the campaigns domain dependencies.

func (*Service) AddComment

AddComment starts a thread (on a block or the whole email) or replies to one, and notifies the members it mentions.

func (*Service) ApplySynced

func (s *Service) ApplySynced(ctx context.Context, ws *store.Workspace, p *authz.Principal, kind, block, label string) (SyncedUses, []uuid.UUID, error)

ApplySynced puts a synced block's new content (block, one element marked rc-synced) into every draft and scheduled campaign holding that kind, as a new version saved by p (source "synced", label). Campaigns in an approval, sending or paused, and sent ones, keep their content; the counts say how many of each there were, and changed lists the campaigns that got the block.

func (*Service) Archive

func (s *Service) Archive(ctx context.Context, ws *store.Workspace, by *uuid.UUID, id uuid.UUID, archive bool) error

Archive takes a sent campaign off the list; Unarchive puts it back.

func (*Service) Bulk

Bulk archives, unarchives, deletes or tags campaigns, each on its own: one that can't (a draft can't be archived, a sent one deleted) is skipped with the reason and the others go on. Each change is audited.

func (*Service) Calendar

func (s *Service) Calendar(ctx context.Context, ws *store.Workspace, from, to time.Time) (CampaignCalendar, error)

Calendar lists scheduled and sent campaigns and digest issues to come.

func (*Service) CampaignName

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

CampaignName is a campaign's name, or a 404 when the workspace has no such campaign.

func (*Service) Checks

Checks runs the content checks on the composer's current content.

func (*Service) Comments

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

Comments lists a campaign's threads.

func (*Service) Context

Context returns senders, lists, segments, tokens, team and the route.

func (*Service) CountAudience

CountAudience counts the recipients of a definition.

func (*Service) CountSynced

func (s *Service) CountSynced(ctx context.Context, ws *store.Workspace, kind string) (SyncedUses, error)

CountSynced counts the campaigns holding a kind of synced block.

func (*Service) Create

Create makes a draft and returns it.

func (*Service) CreateForAgent

func (s *Service) CreateForAgent(ctx context.Context, ws *store.Workspace, p *authz.Principal, name string, in AgentContent) (ComposerCampaign, error)

CreateForAgent makes a draft an agent wrote: its MJML compiled and checked on the server (an MJML error is refused), the workspace's default sender as for any new draft, and a first version "created by an agent". It leaves the audit entry to the caller.

func (*Service) CreateRetry

func (s *Service) CreateRetry(ctx context.Context, ws *store.Workspace, p *authz.Principal, issue uuid.UUID) (ComposerCampaign, error)

CreateRetry makes the retry of an issue: the issue as everyone else got it (an A/B test's winner, as a plain campaign), from the same sender with the same settings and language versions, to the issue's lists and segments kept to its addresses blocked for the sender's reputation that haven't had a retry yet. An issue has one retry at a time.

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

CreateReviewLink makes a review link for the campaign's current saved version (named "Shared for review" when it has no name, so it isn't pruned from the history).

func (*Service) Delete

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

Delete moves a draft, or a campaign that sent nothing, to Deleted; its open approval request closes. Sent campaigns are archived instead.

func (*Service) Detail

Detail loads a campaign for the composer.

func (*Service) DetailIn

func (s *Service) DetailIn(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, lang string) (ComposerCampaign, error)

DetailIn loads a campaign for the composer with the content of one language version ("" or the source language: the source).

func (*Service) Dismiss

Dismiss records why someone dismissed a warning.

func (*Service) DraftFromPost

func (s *Service) DraftFromPost(ctx context.Context, ws *store.Workspace, p *authz.Principal, name, subject, preheader, src string) (uuid.UUID, error)

DraftFromPost makes a campaign draft from a web-only post of the publication website ("Send as a campaign", design expansion phase 7): the post's title as the subject, its excerpt as the preheader, its blocks as the email. The audience is left for the person to pick.

Like a new draft in the composer, it starts from a sender the person may send from: the workspace's default when it's within their scope.

func (*Service) Duplicate

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

Duplicate copies a campaign (any status) into a new draft.

func (*Service) FollowUp

FollowUp makes the follow-up draft: a copy of the campaign with its own subject, sent to a segment of the report's bucket.

func (*Service) FollowUpCounts

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

FollowUpCounts counts the report's buckets for a follow-up.

func (*Service) Leave

func (s *Service) Leave(ctx context.Context, p *authz.Principal, id uuid.UUID) error

Leave records that the caller closed the campaign. An API key or agent was never there, and doesn't take the person who made it away.

func (*Service) List

List returns one page of campaigns with their route and readiness.

func (*Service) Mentionable

func (s *Service) Mentionable(ctx context.Context, ws *store.Workspace) (ComposerMemberList, error)

Mentionable lists the members who can be @mentioned: the workspace's people, by name.

func (*Service) NameVersion

func (s *Service) NameVersion(ctx context.Context, ws *store.Workspace, id uuid.UUID, version int, in ComposerNameVersion) (ComposerVersion, error)

NameVersion names one version of the history.

func (*Service) Present

Present records that the caller has the campaign open and returns who else does.

func (*Service) Preview

Preview renders the campaign for a contact (or a sample).

func (*Service) PreviewContacts

func (s *Service) PreviewContacts(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, query string) (ComposerPreviewContactList, error)

PreviewContacts searches contacts of the audience.

func (*Service) PurgeDeleted

func (s *Service) PurgeDeleted(ctx context.Context) (int64, error)

PurgeDeleted removes campaigns deleted more than 30 days ago.

func (*Service) ResolveThread

func (s *Service) ResolveThread(ctx context.Context, ws *store.Workspace, p *authz.Principal, id, threadID uuid.UUID, in ComposerResolveInput) error

ResolveThread resolves a thread, or opens it again.

func (*Service) Restore

Restore copies a version on top of the history.

func (*Service) RestoreDeleted

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

RestoreDeleted brings a deleted campaign back within 30 days.

func (*Service) RestoreExactly

func (s *Service) RestoreExactly(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, version, baseVersion int, settings *ComposerContentSettings) (ComposerSavedContent, error)

RestoreExactly is Restore for an undo (Send Readiness's fixes): it puts a version back only while the campaign is still at baseVersion; when anyone saved since, it fails with the version conflict instead of merging their edit. settings, when set, are the content settings the version had (the undo puts them back too); nil keeps the campaign's.

func (*Service) Review

func (s *Service) Review(ctx context.Context, token, client string) (ReviewPage, error)

Review is the page behind a review link.

func (*Service) ReviewComment

func (s *Service) ReviewComment(ctx context.Context, token, client string, in ReviewCommentInput) (ComposerThread, error)

ReviewComment is a reviewer's comment through a link. The campaign's members see it in the composer's Comments, marked as a reviewer's.

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

ReviewLinks lists a campaign's working review links.

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

RevokeReviewLink stops a review link from working.

func (*Service) SampleRender

func (s *Service) SampleRender(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, variant string) (ComposerPreview, int, error)

SampleRender is the saved campaign (one A/B variant: A, B or C) as the synthetic sample contact gets it, and the saved version it comes from. Real renders (internal/renders, CO-13) send it to a service outside ReputeCast, so no contact's data leaves the instance.

func (*Service) Save

Save stores a new version of the content.

func (*Service) SaveForAgent

func (s *Service) SaveForAgent(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in AgentContent) (AgentSaved, error)

SaveForAgent stores an agent's change to a draft as its next version, like a person's save that sends no HTML: the MJML is compiled and checked on the server (an MJML error is refused), the head's title and preview follow the subject and preheader, A/B variants keep their content, and approvals and Send Readiness see the change. It never cancels a person's approval or pending request (409 approval_would_cancel), and it leaves the audit entry to the caller.

func (*Service) SaveIn

SaveIn stores a new version of one language version's content ("" or the source language: the source).

func (*Service) SendTest

SendTest delivers test emails through the System route. Content Writers and other members without campaigns:send can only send to themselves.

func (*Service) Summary

func (s *Service) Summary(ctx context.Context, ws *store.Workspace, days int) (CampaignSummary, error)

Summary returns the last-N-days totals across campaigns.

func (*Service) Tags

func (s *Service) Tags(ctx context.Context, ws *store.Workspace) (CampaignTags, error)

Tags returns the tags in use.

func (*Service) Undismiss

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

Undismiss counts a dismissed warning as a warning again (Undo).

func (*Service) UnlinkSynced

func (s *Service) UnlinkSynced(ctx context.Context, ws *store.Workspace, p *authz.Principal, kind, label string) (SyncedUses, []uuid.UUID, error)

UnlinkSynced unlinks a deleted synced block (R4.A3) in every draft and scheduled campaign holding it: its sections stay as ordinary content, in a new version saved by p (source "synced", label). Campaigns in an approval, sending or paused, and sent ones, keep theirs; the composer offers to unlink a block that's gone.

func (*Service) Update

Update applies an UpdateCampaign.

func (*Service) Version

func (s *Service) Version(ctx context.Context, ws *store.Workspace, id uuid.UUID, version int) (ComposerVersionDetail, error)

Version returns one version.

func (*Service) Versions

func (s *Service) Versions(ctx context.Context, ws *store.Workspace, id uuid.UUID, page VersionsPage) (ComposerVersionList, error)

Versions lists the history of a campaign, one page at a time.

type SyncedUses

type SyncedUses struct {
	// Drafts and Scheduled get the change.
	Drafts    int `json:"drafts"`
	Scheduled int `json:"scheduled"`
	// Held are waiting for or holding an approval, sending or paused: a
	// change doesn't reach them, so an approved email stays as approved.
	Held int `json:"held"`
	// Sent keep the version they went out with.
	Sent int `json:"sent"`
}

SyncedUses counts the campaigns holding a synced block, by what a change to it does to them (review 2026-10, CO-11).

type ThreadPath

type ThreadPath struct {
	CampaignPath
	ThreadID string `path:"threadId" format:"uuid"`
}

ThreadPath adds a comment thread's {threadId}.

type TranslationContent

type TranslationContent struct {
	Language     string
	Subject      string
	Preheader    string
	MJML         string
	HTML         string
	PlainText    string
	ABTest       json.RawMessage
	Version      int
	VersionCount int
	ContentHash  string
	UpdatedAt    time.Time
	UpdatedBy    string
	AutosavedAt  *time.Time
}

TranslationContent is a language version's content.

type Translations

type Translations interface {
	// SourceLanguage is the language the campaign is written in.
	SourceLanguage(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) (string, error)
	// Content returns a language version's content (404 when it has none).
	Content(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, lang string) (TranslationContent, error)
	// Save stores a new version of a language version.
	Save(ctx context.Context, ws *store.Workspace, p *authz.Principal, campaignID uuid.UUID, lang string, in ComposerSaveContent, minify bool) (ComposerSavedContent, error)
	// Choose picks the version a reader with this contact language gets.
	Choose(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, contactLanguage string) (lang, reason string, err error)
	// Ready lists the languages whose version is sent, the source first.
	Ready(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) ([]string, error)
}

Translations are a campaign's language versions (internal/languages): the content endpoints take `language` and hand language versions to it.

type VersionPath

type VersionPath struct {
	CampaignPath
	Version int `path:"version" minimum:"1"`
}

VersionPath adds a {version}.

type VersionsPage

type VersionsPage struct {
	Limit int
	// Before lists versions older than this one (0: from the newest).
	Before int
	// Named lists named versions only.
	Named bool
}

VersionsPage asks for one page of the history.

Jump to

Keyboard shortcuts

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