digests

package
v1.3.1 Latest Latest
Warning

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

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

Documentation

Overview

Package digests runs recurring and RSS digests (design expansion, phase 3, M20): a campaign that builds an issue on a schedule from a feed's new items and sends it.

A digest reads a feed (RSS 2.0, Atom 1.0, JSON Feed 1.1, or a WordPress site of the integrations hub) every 30 minutes while it is on and again at preparation, through the SSRF guard (package feed). Its template is a campaign the composer edits in digest mode, with the Feed items block and feed tokens. Every issue is a campaign too: it is built at preparation, runs Send Readiness and the approval rules, and goes out through the sending engine on its owner's authority, so there is no second sending pipeline. A held issue waits for a person; nothing is sent anyway.

Index

Constants

View Source
const (
	FieldImage      = "image"
	FieldTitle      = "title"
	FieldDate       = "date"
	FieldAuthor     = "author"
	FieldCategories = "categories"
	FieldExcerpt    = "excerpt"
	FieldButton     = "button"
)

Fields of a feed item the block can show.

View Source
const (
	ViaSchedule    = "schedule"
	ViaPreparation = "preparation"
	ViaPlugin      = "plugin"
	ViaPerson      = "person"
	ViaSetup       = "setup"
)

How the feed was read: the 30-minute schedule, at preparation, because the WordPress plugin reported a post, by a person (Read now), or while the digest was set up.

View Source
const (
	FreqDaily   = "daily"
	FreqWeekly  = "weekly"
	FreqMonthly = "monthly"
	// FreqItems prepares an issue as soon as Count new items arrived, at
	// most once a day, inside a sending window.
	FreqItems = "items"
)

Frequencies of a digest's schedule.

View Source
const FeedRetry = 15 * time.Minute

FeedRetry is how often a feed that failed at preparation is read again, until the send time.

View Source
const GmailClip = 102 * 1024

GmailClip is the size from which Gmail clips an email (102 KB).

View Source
const ImageWidth = 552

ImageWidth is the width items' images are copied at: the Cards layout's 552 px (600 minus the 24 px margins). The Grid draws the same copy at 264.

View Source
const ReadEvery = 30 * time.Minute

ReadEvery is how often the feed of a digest that is on is read.

View Source
const RecheckLead = 15 * time.Minute

RecheckLead is how long before the send time Send Readiness runs again on a prepared issue, as for any scheduled campaign.

Variables

AllFields are the fields in the inspector's order.

Functions

func ExpandBlock

func ExpandBlock(mjml string, items []BlockItem, loc *time.Location, lang i18n.Lang) string

ExpandBlock replaces a template's Feed items block with the issue's posts. The block's place is kept with a marker naming its layout, so the composer labels the posts of an issue ("Feed item 1 of 3").

func MarkerFor

func MarkerFor(b DigestFeedBlock) string

MarkerFor writes a block's settings as the template's marker. The JSON never contains "--", which would end the comment.

func Register

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

Register adds the digest operations.

func RegisterJobs

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

RegisterJobs adds the digests' workers and the minute job.

func RenderBlock

func RenderBlock(b DigestFeedBlock, items []BlockItem, loc *time.Location, lang i18n.Lang) string

RenderBlock writes the block for an issue's posts as MJML sections, one per post (two per row in the grid), each marked css-class="rc-feed-item"; each post's column is marked css-class="rc-feed-post" (the composer's canvas labels them). Dates are written in lang, the email's language.

func RenderIssue

func RenderIssue(src string, d IssueData, escape bool) (string, error)

RenderIssue fills in an issue's tokens and leaves every other Liquid span as it is, for the send's per-recipient render: a span reads the issue when it uses feed, issue, a loop variable of a loop over the issue's items, or a variable assigned from them. Block tags go with their opening tag, so {% if first_name %}…{{ issue.number }}…{% endif %} keeps its condition and gets the number. A condition that mixes both (issue.items.size > 1 and first_name) is decided now, without the contact. escape writes the values for HTML.

func SaysZeroMore

func SaysZeroMore(subject string) bool

SaysZeroMore reports whether a rendered subject counts "0 more".

func UsesFeedTokens

func UsesFeedTokens(src string) bool

UsesFeedTokens reports whether a subject, preheader or body reads the issue.

func WrapCount

func WrapCount(subject string) (string, bool)

WrapCount puts the "and N more" of a subject inside {% if issue.items.size > 1 %}…{% endif %}, so it only shows with two or more items. ok is false when the subject has no such count.

Types

type Approvals

type Approvals interface {
	RequestForIssue(ctx context.Context, ws *store.Workspace, ownerID, campaignID uuid.UUID, in approvals.IssueRequest) (uuid.UUID, error)
	SendRecheck(ctx context.Context, campaignID uuid.UUID) (approvals.SendRecheck, error)
	CampaignChanged(ctx context.Context, ws *store.Workspace, id uuid.UUID)
}

Approvals asks for approval of issues in their owner's name and checks, as an issue starts, that its approval still covers it (approvals.Service).

type BlockItem

type BlockItem struct {
	ID         string
	Title      string
	URL        string
	Author     string
	Published  *time.Time
	Categories []string
	Excerpt    string
	// Image is the library copy (or the fallback); ImageAlt its alt text.
	Image    string
	ImageAlt string
	// AltFromTitle: the image has no alt text of its own, so the title is used.
	AltFromTitle bool
	// Fallback: the post has no image and shows the block's fallback image.
	Fallback bool
}

BlockItem is a post as the block shows it.

type Checks

type Checks interface {
	Run(ctx context.Context, ws *store.Workspace, id uuid.UUID, o readiness.RunOptions) (readiness.ReadinessRun, error)
	Latest(ctx context.Context, campaignID uuid.UUID) (*readiness.ReadinessRun, error)
	Audience(ctx context.Context, ws *store.Workspace, raw json.RawMessage) (readiness.AudienceFacts, error)
}

Checks runs Send Readiness on issues and counts audiences (readiness.Service).

type DigestApprovals

type DigestApprovals struct {
	Needed bool              `json:"needed"`
	Rules  []DigestRuleMatch `json:"rules"`
	// Approvers who can approve issues (not the owner).
	Approvers []string `json:"approvers"`
}

DigestApprovals is what the approval policy does to each issue.

type DigestAudience

type DigestAudience struct {
	ListIDs    []string `json:"listIds"`
	SegmentIDs []string `json:"segmentIds"`
	// Label is "Product Updates list".
	Label      string `json:"label"`
	Base       int64  `json:"base"`
	Suppressed int64  `json:"suppressed"`
	Role       int64  `json:"role"`
	Duplicates int64  `json:"duplicates"`
	Stopped    int64  `json:"stopped"`
	Final      int64  `json:"final"`
	Empty      bool   `json:"empty"`
}

DigestAudience is who each issue goes to, counted now.

type DigestBlockChecks

type DigestBlockChecks struct {
	// MaxBytes is the issue's size with the block's maximum of posts.
	MaxPosts int `json:"maxPosts"`
	MaxBytes int `json:"maxBytes"`
	Limit    int `json:"limit"`
	// Images counts the preview's images, AltFromTitle those whose alt text
	// is the post's title, Fallback the posts without an image.
	Images       int `json:"images"`
	AltFromTitle int `json:"altFromTitle"`
	Fallback     int `json:"fallback"`
	// Links counts the block's links (each post's title and button).
	Links int `json:"links"`
	// FitPosts is how many posts fit before Gmail clips.
	FitPosts int `json:"fitPosts"`
	// Bytes is the size of the issue the preview shows (the next issue as it stands).
	Bytes int `json:"bytes"`
}

DigestBlockChecks are the checks of the Feed items block.

type DigestCheck

type DigestCheck struct {
	CampaignID string `json:"campaignId"`
	RunID      string `json:"runId"`
	Verdict    string `json:"verdict"`
}

DigestCheck is the next issue checked by Send Readiness.

type DigestCreateInput

type DigestCreateInput struct {
	Name string `json:"name,omitempty" maxLength:"200"`
	// Source is a connected WordPress site (SiteID) or a feed or page address (FeedURL).
	Source  string `json:"source" enum:"url,wordpress"`
	SiteID  string `json:"siteId,omitempty" format:"uuid"`
	FeedURL string `json:"feedUrl,omitempty" maxLength:"500"`
}

DigestCreateInput starts a digest from the type picker.

type DigestDetail

type DigestDetail struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	State      string `json:"state" enum:"off,on,paused"`
	Mode       string `json:"mode" enum:"auto,draft"`
	TemplateID string `json:"templateId"`
	// TemplateVersion and TemplateSavedAt describe the template's latest save.
	TemplateVersion int        `json:"templateVersion"`
	TemplateSavedAt *time.Time `json:"templateSavedAt,omitempty"`
	Archive         bool       `json:"archive"`
	// Source and the feed.
	Source  string        `json:"source" enum:"url,wordpress"`
	FeedURL string        `json:"feedUrl"`
	Site    *DigestSite   `json:"site,omitempty"`
	Filters DigestFilters `json:"filters"`
	// CategoryOptions and TagOptions are the feed's own terms.
	CategoryOptions []string         `json:"categoryOptions"`
	TagOptions      []string         `json:"tagOptions"`
	Feed            DigestFeedStatus `json:"feed"`
	// Schedule.
	Schedule     DigestSchedule `json:"schedule"`
	PrepareHours int            `json:"prepareHours"`
	LateHours    int            `json:"lateHours"`
	// Audience, sender, route and auto-pause limits (the template's).
	Audience   DigestAudience   `json:"audience"`
	Sender     *DigestSender    `json:"sender,omitempty"`
	Route      DigestRoute      `json:"route"`
	Thresholds DigestThresholds `json:"thresholds"`
	Approvals  DigestApprovals  `json:"approvals"`
	// Owner and history.
	Owner      *DigestPerson `json:"owner,omitempty"`
	OwnerSince *time.Time    `json:"ownerSince,omitempty"`
	FirstOnAt  *time.Time    `json:"firstOnAt,omitempty"`
	Pause      *DigestPause  `json:"pause,omitempty"`
	// Next is the issue being collected or prepared; nil while off or paused.
	Next *DigestNextIssue `json:"next,omitempty"`
	// NextSend is the next send time by the schedule (for the turn-on confirmation).
	NextSend *time.Time `json:"nextSend,omitempty"`
	// SentIssues counts sent issues; FirstSentAt is when #1 went out.
	SentIssues  int           `json:"sentIssues"`
	FirstSentAt *time.Time    `json:"firstSentAt,omitempty"`
	CreatedBy   *DigestPerson `json:"createdBy,omitempty"`
	CreatedAt   time.Time     `json:"createdAt"`
	UpdatedAt   time.Time     `json:"updatedAt"`
	// Helpers name who can help with what a member can't do ("Ask Sofia
	// Rossi, Marcus Chen or Linh Nguyen").
	SendHelpers  []string `json:"sendHelpers"`
	EditHelpers  []string `json:"editHelpers"`
	PauseHelpers []string `json:"pauseHelpers"`
}

DigestDetail is a digest with everything its overview and settings show.

type DigestFeedBlock

type DigestFeedBlock struct {
	// Layout: list (title and excerpt), cards (the image above the text,
	// one post per row) or grid (two per row, stacked on mobile).
	Layout string   `json:"layout" enum:"list,cards,grid"`
	Fields []string `json:"fields" maxItems:"7" doc:"image, title (linked), date, author, categories, excerpt, button"`
	// ExcerptWords is the excerpt's length in words.
	ExcerptWords int    `json:"excerptWords" minimum:"5" maximum:"200"`
	ButtonText   string `json:"buttonText" maxLength:"60"`
	// Max is how many posts an issue shows, 1 to 20.
	Max   int    `json:"max" minimum:"1" maximum:"20"`
	Order string `json:"order" enum:"newest,oldest"`
	// Overflow is what happens to more new posts than fit: drop (send the
	// newest and leave out the rest) or keep (they count as new until sent).
	Overflow string `json:"overflow" enum:"drop,keep"`
	// Fallback is the image of posts without one (a library URL).
	Fallback     string `json:"fallback,omitempty" maxLength:"500"`
	FallbackName string `json:"fallbackName,omitempty" maxLength:"200"`
}

DigestFeedBlock is the Feed items block's settings.

func BlockOf

func BlockOf(mjml string) (DigestFeedBlock, bool)

BlockOf reads a template's Feed items block; ok is false without one.

func DefaultBlock

func DefaultBlock() DigestFeedBlock

DefaultBlock is the "Blog digest" starter's block.

func (DigestFeedBlock) Select

func (b DigestFeedBlock) Select(items []BlockItem) (shown, rest []BlockItem)

Select picks the posts an issue shows from its new items (newest first): at most Max, in the block's order. The rest are left out (drop) or stay new for the next issue (keep).

type DigestFeedError

type DigestFeedError struct {
	// Kind: unreachable, timeout, blocked (the SSRF guard), too_large,
	// status (an HTTP error), redirects, address, not_feed, no_feed_link.
	Kind   string `json:"kind"`
	Host   string `json:"host"`
	URL    string `json:"url"`
	Status int    `json:"status,omitempty"`
	// Detail is the English sentence ("blog.acme.io didn't answer: …").
	Detail string `json:"detail"`
	// Lines are the first lines of what answered instead of a feed.
	Lines []string        `json:"lines"`
	Hops  []DigestFeedHop `json:"hops"`
	// Seconds is the read's time limit, for timeouts.
	Seconds int `json:"seconds,omitempty"`
}

DigestFeedError says why a read failed, with what the guard checked.

type DigestFeedHop

type DigestFeedHop struct {
	URL      string `json:"url"`
	Status   int    `json:"status"`
	Location string `json:"location,omitempty"`
}

DigestFeedHop is one address answered on the way to the feed.

type DigestFeedItem

type DigestFeedItem struct {
	ID         string     `json:"id"`
	Title      string     `json:"title"`
	URL        string     `json:"url"`
	Author     string     `json:"author"`
	Published  *time.Time `json:"published,omitempty"`
	Categories []string   `json:"categories"`
	Tags       []string   `json:"tags"`
	Excerpt    string     `json:"excerpt"`
	// Image is the library copy; ImageAlt its alt text, AltFromTitle when
	// that is the title.
	Image        string `json:"image,omitempty"`
	ImageAlt     string `json:"imageAlt,omitempty"`
	AltFromTitle bool   `json:"altFromTitle"`
	// Fallback: the post has no image, so the block's fallback image is used.
	Fallback bool `json:"fallback"`
	// Status: new (goes in the next issue), sent (in issue SentIn),
	// left_out (by LeftOutBy: category, tag, age), before_start (published
	// before the digest was turned on).
	Status    string `json:"status" enum:"new,sent,left_out,before_start"`
	SentIn    int    `json:"sentIn,omitempty"`
	LeftOutBy string `json:"leftOutBy,omitempty" enum:"category,tag,age,"`
	// FirstSeenVia: plugin, schedule, preparation, person, setup.
	FirstSeenAt  time.Time `json:"firstSeenAt"`
	FirstSeenVia string    `json:"firstSeenVia"`
}

DigestFeedItem is a post of the feed with what the digest does with it.

type DigestFeedPreview

type DigestFeedPreview struct {
	Items []DigestFeedItem `json:"items"`
	// Total is how many items the feed has; the older ones are counted.
	Total        int               `json:"total"`
	OlderSent    []DigestSentCount `json:"olderSent"`
	OlderLeftOut int               `json:"olderLeftOut"`
	OlderBefore  int               `json:"olderBefore"`
	OlderNew     int               `json:"olderNew"`
}

DigestFeedPreview is the newest items with their badges.

type DigestFeedSkip

type DigestFeedSkip struct {
	SendAt time.Time `json:"sendAt"`
	// Kind: unreachable or invalid.
	Kind string `json:"kind"`
}

DigestFeedSkip is an issue skipped because the feed failed.

type DigestFeedStatus

type DigestFeedStatus struct {
	Status string `json:"status" enum:"unread,ok,unreachable,invalid"`
	// URL is the address read (a WordPress site's reported feed).
	URL   string `json:"url"`
	Kind  string `json:"kind,omitempty" enum:"rss,atom,json,"`
	Title string `json:"title"`
	Items int    `json:"items"`
	Bytes int    `json:"bytes"`
	// LastReadVia: plugin (the WordPress plugin reported a post), schedule
	// (the 30-minute read), preparation, person (Read now), setup.
	LastReadAt  *time.Time       `json:"lastReadAt,omitempty"`
	LastReadVia string           `json:"lastReadVia,omitempty"`
	LastOkAt    *time.Time       `json:"lastOkAt,omitempty"`
	Error       *DigestFeedError `json:"error,omitempty"`
	// MovedTo is offered as "Use the new address" after a permanent redirect.
	MovedTo string `json:"movedTo,omitempty"`
	// Waiting counts the new items for the next issue and LeftOut the newest
	// items the filters leave out.
	Waiting int `json:"waiting"`
	LeftOut int `json:"leftOut"`
}

DigestFeedStatus is the feed as last read.

type DigestFeedTry

type DigestFeedTry struct {
	At    time.Time `json:"at"`
	Error string    `json:"error"`
	Kind  string    `json:"kind"`
}

DigestFeedTry is a failed read at preparation.

type DigestFilters

type DigestFilters struct {
	// Categories picked: an item in any of them goes in. Empty: no category filter.
	Categories []string `json:"categories"`
	Tags       []string `json:"tags"`
	// MaxAgeDays leaves out items older than this many days (nil: off).
	MaxAgeDays  *int   `json:"maxAgeDays,omitempty" minimum:"1" maximum:"365"`
	StartMode   string `json:"startMode" enum:"after_on,latest"`
	StartLatest int    `json:"startLatest" minimum:"1" maximum:"20"`
}

DigestFilters are the feed's filters and the first issue's starting point.

type DigestFindInput

type DigestFindInput struct {
	Address string `json:"address" minLength:"1" maxLength:"500"`
}

DigestFindInput is an address typed in the setup.

type DigestFound

type DigestFound struct {
	OK bool `json:"ok"`
	// URL is the feed's address; Page the page it was linked from.
	URL   string `json:"url,omitempty"`
	Page  string `json:"page,omitempty"`
	Kind  string `json:"kind,omitempty"`
	Title string `json:"title,omitempty"`
	Items int    `json:"items"`
	Bytes int    `json:"bytes"`
	// Moved is the address a permanent redirect leads to.
	Moved string           `json:"moved,omitempty"`
	Hops  []DigestFeedHop  `json:"hops"`
	Error *DigestFeedError `json:"error,omitempty"`
	// Preview is the feed's newest items.
	Preview []DigestFeedItem `json:"preview"`
}

DigestFound is the feed found from an address.

type DigestHistory

type DigestHistory struct {
	Items []DigestHistoryItem `json:"items"`
}

DigestHistory is the digest's recent history, newest first.

type DigestHistoryItem

type DigestHistoryItem struct {
	// Kind: left_out (a new post the filters leave out), goes_in (a new post
	// for the next issue), sent, skipped, not_sent, turned_on, paused, created.
	Kind string    `json:"kind" enum:"left_out,goes_in,sent,skipped,not_sent,turned_on,paused,created"`
	At   time.Time `json:"at"`
	// Post facts (left_out, goes_in).
	Title     string     `json:"title,omitempty"`
	Category  string     `json:"category,omitempty"`
	LeftOutBy string     `json:"leftOutBy,omitempty"`
	DraftList string     `json:"draftList,omitempty"`
	Via       string     `json:"via,omitempty"`
	Published *time.Time `json:"published,omitempty"`
	// Issue facts (sent, skipped, not_sent).
	Number     int        `json:"number,omitempty"`
	Recipients int64      `json:"recipients,omitempty"`
	ApprovedBy string     `json:"approvedBy,omitempty"`
	ApprovedAt *time.Time `json:"approvedAt,omitempty"`
	SkipReason string     `json:"skipReason,omitempty"`
	SendAt     *time.Time `json:"sendAt,omitempty"`
	// Who (turned_on, paused, created, sent: the owner the issue went out for).
	Actor string `json:"actor,omitempty"`
	Owner string `json:"owner,omitempty"`
	Mode  string `json:"mode,omitempty"`
	Note  string `json:"note,omitempty"`
	// BuiltBy is who created the digest, when someone else turned it on.
	BuiltBy     string     `json:"builtBy,omitempty"`
	BuiltMode   string     `json:"builtMode,omitempty"`
	BuiltAt     *time.Time `json:"builtAt,omitempty"`
	PauseReason string     `json:"pauseReason,omitempty"`
}

DigestHistoryItem is a line of the digest's history. The screen words it from these facts.

type DigestIssue

type DigestIssue struct {
	ID     string `json:"id"`
	Number *int   `json:"number,omitempty"`
	// Status: collecting, preparing (the feed failed and is retried),
	// prepared, waiting (for approval), held, draft (draft mode, waiting
	// for someone to send it), sending, sent, skipped, not_sent.
	Status   string     `json:"status" enum:"collecting,preparing,prepared,waiting,held,draft,sending,sent,skipped,not_sent"`
	SendAt   *time.Time `json:"sendAt,omitempty"`
	Deadline *time.Time `json:"deadline,omitempty"`
	// SkipReason: no_items, feed, not_approved, held, person.
	SkipReason      string               `json:"skipReason,omitempty" enum:"no_items,feed,not_approved,held,person,"`
	SkipNote        string               `json:"skipNote,omitempty"`
	SkippedBy       string               `json:"skippedBy,omitempty"`
	SkippedAt       *time.Time           `json:"skippedAt,omitempty"`
	HoldReason      string               `json:"holdReason,omitempty" enum:"readiness,changes,rejected,no_approvers,"`
	FirstIssue      bool                 `json:"firstIssue"`
	Posts           int                  `json:"posts"`
	PostsDelta      *int                 `json:"postsDelta,omitempty"`
	Recipients      *int64               `json:"recipients,omitempty"`
	Estimated       bool                 `json:"estimated"`
	RecipientsDelta *int64               `json:"recipientsDelta,omitempty"`
	HumanOpens      *float64             `json:"humanOpens,omitempty"`
	HumanOpensDelta *float64             `json:"humanOpensDelta,omitempty"`
	Clicks          *float64             `json:"clicks,omitempty"`
	ClicksDelta     *float64             `json:"clicksDelta,omitempty"`
	Delivered       *float64             `json:"delivered,omitempty"`
	Approval        *DigestIssueApproval `json:"approval,omitempty"`
	NeedsApproval   bool                 `json:"needsApproval"`
	CampaignID      string               `json:"campaignId,omitempty"`
	FeedTries       []DigestFeedTry      `json:"feedTries"`
	PreparedAt      *time.Time           `json:"preparedAt,omitempty"`
	SentAt          *time.Time           `json:"sentAt,omitempty"`
}

DigestIssue is a row of the issues table.

type DigestIssueApproval

type DigestIssueApproval struct {
	ID          string        `json:"id"`
	Status      string        `json:"status"`
	RequestedAt time.Time     `json:"requestedAt"`
	DecidedAt   *time.Time    `json:"decidedAt,omitempty"`
	DecidedBy   *DigestPerson `json:"decidedBy,omitempty"`
	Rules       []string      `json:"rules"`
}

DigestIssueApproval is an issue's approval request.

type DigestIssueInfo

type DigestIssueInfo struct {
	CampaignID string `json:"campaignId"`
	DigestID   string `json:"digestId"`
	DigestName string `json:"digestName"`
	IssueID    string `json:"issueId"`
	// Number is the issue's number, or the one it gets when it goes out.
	Number     int        `json:"number"`
	Status     string     `json:"status" enum:"collecting,preparing,prepared,waiting,held,draft,sending,sent,skipped,not_sent"`
	HoldReason string     `json:"holdReason,omitempty" enum:"readiness,changes,rejected,no_approvers,"`
	Mode       string     `json:"mode" enum:"auto,draft"`
	PreparedAt *time.Time `json:"preparedAt,omitempty"`
	SendAt     *time.Time `json:"sendAt,omitempty"`
	// Deadline is the late limit: not out by then, the issue is skipped.
	Deadline *time.Time    `json:"deadline,omitempty"`
	Owner    *DigestPerson `json:"owner,omitempty"`
	// Posts are the issue's posts, in its order.
	Posts []DigestFeedItem `json:"posts"`
	// Since is what changed since the last approved issue (nil for the first).
	Since *DigestIssueSince `json:"since,omitempty"`
	// PreviousCampaignID is the previous sent issue, for the report's comparison.
	PreviousCampaignID string `json:"previousCampaignId,omitempty"`
	PreviousNumber     int    `json:"previousNumber,omitempty"`
	// ReleaseHelpers name who can release a held issue (campaigns:send).
	ReleaseHelpers []string `json:"releaseHelpers"`
}

DigestIssueInfo is a campaign's digest issue, for the screens that show a campaign: the approvals inbox and review, Review & send and the report.

type DigestIssueInfos

type DigestIssueInfos struct {
	Items []DigestIssueInfo `json:"items"`
}

DigestIssueInfos are the digest issues among some campaigns.

type DigestIssueReadiness

type DigestIssueReadiness struct {
	RunID    string    `json:"runId"`
	Verdict  string    `json:"verdict"`
	Passed   int       `json:"passed"`
	Warnings int       `json:"warnings"`
	Blocks   int       `json:"blocks"`
	RanAt    time.Time `json:"ranAt"`
	// Blocking are the titles of the checks that block.
	Blocking []string `json:"blocking"`
}

DigestIssueReadiness is the latest Send Readiness of an issue.

type DigestIssueRef

type DigestIssueRef struct {
	ID     string     `json:"id"`
	Number int        `json:"number"`
	Status string     `json:"status" enum:"collecting,preparing,prepared,waiting,held,draft,sending,sent,skipped,not_sent"`
	SendAt *time.Time `json:"sendAt,omitempty"`
	Posts  int        `json:"posts"`
	// NeedsApproval: the approval rules match this issue (or would at preparation).
	NeedsApproval bool `json:"needsApproval"`
	// HumanOpens of a sent issue, and how it compares with the issue before (points).
	HumanOpens      *float64 `json:"humanOpens,omitempty"`
	HumanOpensDelta *float64 `json:"humanOpensDelta,omitempty"`
}

DigestIssueRef is an issue in a list row: the next one or the last sent.

type DigestIssueSince

type DigestIssueSince struct {
	Number     int        `json:"number"`
	ApprovedAt *time.Time `json:"approvedAt,omitempty"`
	SentAt     *time.Time `json:"sentAt,omitempty"`
	// Changed: template, audience, route, schedule; empty when nothing changed.
	Changed []string `json:"changed"`
}

DigestIssueSince compares an issue with the last approved one.

type DigestIssues

type DigestIssues struct {
	Items []DigestIssue `json:"items"`
}

DigestIssues is a digest's issues, newest first.

type DigestList

type DigestList struct {
	Items []DigestListItem `json:"items"`
}

DigestList is the workspace's digests.

type DigestListItem

type DigestListItem struct {
	ID       string          `json:"id"`
	Name     string          `json:"name"`
	State    string          `json:"state" enum:"off,on,paused"`
	Mode     string          `json:"mode" enum:"auto,draft"`
	Source   DigestSourceRef `json:"source"`
	Schedule DigestSchedule  `json:"schedule"`
	Next     *DigestIssueRef `json:"next,omitempty"`
	Last     *DigestIssueRef `json:"last,omitempty"`
	Owner    *DigestPerson   `json:"owner,omitempty"`
}

DigestListItem is one row of Campaigns › Recurring.

type DigestNextAcross

type DigestNextAcross struct {
	DigestID, DigestName string
	Number               int
	SendAt               time.Time
	Timezone             string
	Posts                int
	Status               string
	NeedsApproval        bool
}

DigestNextAcross is the soonest issue among a workspace's digests that are on, for the overview's "Next scheduled campaign".

type DigestNextIssue

type DigestNextIssue struct {
	ID     string `json:"id"`
	Number int    `json:"number"`
	Status string `json:"status" enum:"collecting,preparing,prepared,waiting,held,draft,sending,sent,skipped,not_sent"`
	// SendAt is unknown for an item-count schedule until it is prepared.
	SendAt    *time.Time `json:"sendAt,omitempty"`
	PrepareAt *time.Time `json:"prepareAt,omitempty"`
	Deadline  *time.Time `json:"deadline,omitempty"`
	Posts     int        `json:"posts"`
	// Fit is how many posts the Feed items block shows at most.
	Fit        int              `json:"fit"`
	Recipients int64            `json:"recipients"`
	Subject    string           `json:"subject"`
	Preheader  string           `json:"preheader"`
	Items      []DigestFeedItem `json:"items"`
	Subjects   []DigestSubject  `json:"subjects"`
	CampaignID string           `json:"campaignId,omitempty"`
	// Waiting/held details.
	Approval   *DigestIssueApproval `json:"approval,omitempty"`
	HoldReason string               `json:"holdReason,omitempty" enum:"readiness,changes,rejected,no_approvers,"`
	HeldAt     *time.Time           `json:"heldAt,omitempty"`
	PreparedAt *time.Time           `json:"preparedAt,omitempty"`
	FeedTries  []DigestFeedTry      `json:"feedTries"`
	// NextTry is the next read of a feed that failed at preparation.
	NextTry *time.Time `json:"nextTry,omitempty"`
	// Readiness of a prepared issue.
	Readiness *DigestIssueReadiness `json:"readiness,omitempty"`
}

DigestNextIssue is the issue being collected (or prepared).

type DigestPath

type DigestPath struct {
	api.WorkspaceInput
	DigestID string `path:"digestId" format:"uuid"`
}

DigestPath is the {workspace}/{digestId} of digest operations.

type DigestPause

type DigestPause struct {
	At *time.Time `json:"at,omitempty"`
	By string     `json:"by,omitempty"`
	// Reason: person, owner (the owner lost campaigns:send, was
	// deactivated or left) or feed (three feed failures in a row).
	Reason string `json:"reason" enum:"person,owner,feed"`
	Note   string `json:"note,omitempty"`
	// From and To are the owner's roles before and after (owner reason);
	// Left is true when the owner was deactivated or left.
	From string `json:"from,omitempty"`
	To   string `json:"to,omitempty"`
	Left bool   `json:"left,omitempty"`
	// Notified are the members told.
	Notified []string `json:"notified"`
	// Skips are the send times of the issues skipped because of the feed.
	Skips []DigestFeedSkip `json:"skips"`
}

DigestPause says why a digest is paused.

type DigestPauseInput

type DigestPauseInput struct {
	Note string `json:"note,omitempty" maxLength:"500"`
}

DigestPauseInput pauses a digest, with an optional note.

type DigestPerson

type DigestPerson struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Initials string `json:"initials"`
	Color    string `json:"color"`
}

DigestPerson is a member as the digest screens show them.

type DigestPreview

type DigestPreview struct {
	Number    int    `json:"number"`
	Subject   string `json:"subject"`
	Preheader string `json:"preheader"`
	HTML      string `json:"html"`
	Posts     int    `json:"posts"`
	// Empty: there are no new posts yet; the preview uses the newest ones.
	Empty bool `json:"empty"`
}

DigestPreview is the next issue as a reader would get it now.

type DigestReadNow

type DigestReadNow struct {
	OK          bool             `json:"ok"`
	NotModified bool             `json:"notModified"`
	Items       int              `json:"items"`
	New         int              `json:"new"`
	Error       *DigestFeedError `json:"error,omitempty"`
}

DigestReadNow is a read of the feed started by a person.

type DigestRender

type DigestRender struct {
	Preview string `json:"preview"`
	// Number is the issue's number; Count how many posts the preview has.
	Number int `json:"number"`
	Count  int `json:"count"`
	// MJML is the block's sections for the canvas.
	MJML      string            `json:"mjml"`
	Items     []DigestFeedItem  `json:"items"`
	Subject   string            `json:"subject"`
	Preheader string            `json:"preheader"`
	Subjects  []DigestSubject   `json:"subjects"`
	Sizes     []DigestSize      `json:"sizes"`
	Checks    DigestBlockChecks `json:"checks"`
	// SendAt is the next issue's send time.
	SendAt *time.Time `json:"sendAt,omitempty"`
	// Tokens are the feed tokens' values for the next issue (the token menu).
	Tokens []DigestToken `json:"tokens"`
	// StarterSubject is the Blog digest starter's subject in the email's
	// language ("Use the starter's subject").
	StarterSubject string `json:"starterSubject"`
}

DigestRender is the Feed items block drawn with a preview's posts.

type DigestRenderInput

type DigestRenderInput struct {
	// Preview: next (the next issue as it stands), last (the last sent
	// issue), one or six (the newest posts that pass the filters).
	Preview   string           `json:"preview" enum:"next,last,one,six"`
	Block     *DigestFeedBlock `json:"block,omitempty"`
	Subject   string           `json:"subject,omitempty" maxLength:"998"`
	Preheader string           `json:"preheader,omitempty" maxLength:"500"`
	// MJML is the template as on the canvas (else the saved one).
	MJML string `json:"mjml,omitempty" maxLength:"2000000"`
	// Sizes measures the issue with 1 to 8 posts (slower: it compiles each).
	Sizes bool `json:"sizes,omitempty"`
}

DigestRenderInput is what the composer draws: which posts preview the Feed items block, its settings as they are in the inspector, and the subject and preheader as typed.

type DigestRoute

type DigestRoute struct {
	// Override is true when the digest has its own split instead of the
	// Broadcasts stream's.
	Override bool               `json:"override"`
	Shares   []DigestRouteShare `json:"shares"`
}

DigestRoute is the route issues take.

type DigestRouteShare

type DigestRouteShare struct {
	ProviderID string  `json:"providerId"`
	Name       string  `json:"name"`
	Short      string  `json:"short"`
	Adapter    string  `json:"adapter"`
	Percent    float64 `json:"percent"`
	Status     string  `json:"status"`
	WarmupDay  int     `json:"warmupDay,omitempty"`
	WarmupDays int     `json:"warmupDays,omitempty"`
	// WarmupEnds is the last day of the warm-up plan.
	WarmupEnds *time.Time `json:"warmupEnds,omitempty"`
}

DigestRouteShare is a sending provider of the digest's route.

type DigestRuleMatch

type DigestRuleMatch struct {
	Key   string `json:"key"`
	Label string `json:"label"`
	Short string `json:"short"`
	// Until is when a rule stops matching (a provider's warm-up ends).
	Until *time.Time `json:"until,omitempty"`
	// Threshold is the audience rule's number of recipients (audience_min).
	Threshold int64 `json:"threshold,omitempty"`
}

DigestRuleMatch is an approval rule every issue matches.

type DigestSchedule

type DigestSchedule struct {
	Frequency string `json:"frequency" enum:"daily,weekly,monthly,items"`
	// WeekdaysOnly: a daily digest that skips Saturdays and Sundays.
	WeekdaysOnly bool `json:"weekdaysOnly,omitempty"`
	// Weekday is the day of a weekly digest, and of a monthly digest that
	// goes out on the first such day of the month: 0 Sunday … 6 Saturday.
	Weekday int `json:"weekday" minimum:"0" maximum:"6"`
	// MonthRule is "day" (a day of the month) or "first" (the first Weekday).
	MonthRule string `json:"monthRule,omitempty" enum:"day,first,"`
	// MonthDay is 1–31; months without that day use their last day.
	MonthDay int `json:"monthDay,omitempty" minimum:"0" maximum:"31"`
	// Time is the send time, HH:MM in Timezone.
	Time     string `json:"time" pattern:"^([01][0-9]|2[0-3]):[0-5][0-9]$" example:"08:00"`
	Timezone string `json:"timezone" maxLength:"64" example:"America/New_York"`
	// Count, WindowFrom and WindowUntil describe an item-count schedule.
	Count       int    `json:"count,omitempty" minimum:"0" maximum:"50"`
	WindowFrom  string `json:"windowFrom,omitempty" pattern:"^(([01][0-9]|2[0-3]):[0-5][0-9])?$"`
	WindowUntil string `json:"windowUntil,omitempty" pattern:"^(([01][0-9]|2[0-3]):[0-5][0-9])?$"`
}

DigestSchedule is when a digest's issues go out (digests.schedule).

func DefaultSchedule

func DefaultSchedule(tz string) DigestSchedule

DefaultSchedule is a new digest's: Fridays at 08:00 in the workspace's time zone.

func ParseSchedule

func ParseSchedule(raw json.RawMessage, tz string) DigestSchedule

ParseSchedule reads digests.schedule; a broken value is the default.

func (DigestSchedule) Describe

func (s DigestSchedule) Describe() string

Describe is the schedule in a sentence, in English, for notifications and the audit log ("every Friday at 08:00 America/New_York").

func (DigestSchedule) ItemsSendAt

func (s DigestSchedule) ItemsSendAt(prepared time.Time, lead time.Duration, lastSent *time.Time) time.Time

ItemsSendAt is when an item-count issue prepared at prepared goes out: after the preparation lead, inside the sending window (a time outside it moves to the next window), and on another day than lastSent's.

func (DigestSchedule) NextSend

func (s DigestSchedule) NextSend(t time.Time) time.Time

NextSend is the first send time of a daily, weekly or monthly schedule strictly after t; the zero time for an item-count schedule.

func (DigestSchedule) Validate

func (s DigestSchedule) Validate() (field string, msg i18n.Msg, args i18n.Args)

Validate checks a schedule and says what to change: the field, and the message (with its arguments) to write in the reader's language.

type DigestSender

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

DigestSender is the From of the issues.

type DigestSentCount

type DigestSentCount struct {
	Number int `json:"number"`
	Count  int `json:"count"`
}

DigestSentCount is how many older items went in an issue.

type DigestSettingsInput

type DigestSettingsInput struct {
	Name    string        `json:"name" minLength:"1" maxLength:"200"`
	Archive bool          `json:"archive"`
	Mode    string        `json:"mode" enum:"auto,draft"`
	Source  string        `json:"source" enum:"url,wordpress"`
	SiteID  string        `json:"siteId,omitempty" format:"uuid"`
	FeedURL string        `json:"feedUrl,omitempty" maxLength:"500"`
	Filters DigestFilters `json:"filters"`
	// CategoryFilter: when false, every category goes in (Categories is ignored).
	CategoryFilter bool           `json:"categoryFilter"`
	Schedule       DigestSchedule `json:"schedule"`
	PrepareHours   int            `json:"prepareHours" minimum:"1" maximum:"24"`
	LateHours      int            `json:"lateHours" enum:"6,24,48"`
	// Audience: lists and segments of the issues.
	ListIDs    []string `json:"listIds" maxItems:"20"`
	SegmentIDs []string `json:"segmentIds" maxItems:"20"`
	SenderID   string   `json:"senderId,omitempty" maxLength:"64"`
	// Thresholds are the auto-pause limits (nil: the workspace's).
	Thresholds *DigestThresholdsInput `json:"thresholds,omitempty"`
}

DigestSettingsInput is the digest settings page.

type DigestSite

type DigestSite struct {
	ID string `json:"id"`
	// Host is "blog.acme.io"; Name the site's title.
	Host          string     `json:"host"`
	Name          string     `json:"name"`
	FeedURL       string     `json:"feedUrl"`
	ConnectedAt   time.Time  `json:"connectedAt"`
	ConnectedBy   string     `json:"connectedBy"`
	PluginVersion string     `json:"pluginVersion"`
	LatestPlugin  string     `json:"latestPlugin"`
	LastReportAt  *time.Time `json:"lastReportAt,omitempty"`
	// Status: ok, silent (not heard from in 24 hours) or outdated (a newer
	// plugin is out).
	Status string `json:"status" enum:"ok,silent,outdated"`
	// Items is how many items its feed had at the last read of a digest.
	Items int `json:"items"`
	// DraftRule names the categories the site's post-draft rule turns into
	// drafts, and the list they go to ("Announcements" → "Product Updates").
	DraftCategories []string `json:"draftCategories"`
	DraftList       string   `json:"draftList,omitempty"`
}

DigestSite is a WordPress site of the integrations hub, as a feed source.

type DigestSites

type DigestSites struct {
	Items []DigestSite `json:"items"`
}

DigestSites lists the workspace's WordPress sites.

type DigestSize

type DigestSize struct {
	Posts int `json:"posts"`
	Bytes int `json:"bytes"`
}

DigestSize is the email's size with a number of posts.

type DigestSkipInput

type DigestSkipInput struct {
	Note string `json:"note,omitempty" maxLength:"500"`
}

DigestSkipInput skips an issue, with an optional note.

type DigestSourceRef

type DigestSourceRef struct {
	Kind string `json:"kind" enum:"url,wordpress"`
	// Label is the site's host, or the feed address without its scheme.
	Label      string   `json:"label"`
	Categories []string `json:"categories"`
}

DigestSourceRef names a digest's feed in lists ("blog.acme.io").

type DigestSubject

type DigestSubject struct {
	Items int    `json:"items"`
	Text  string `json:"text"`
	// ZeroMore: the subject reads "…and 0 more" with this many items.
	ZeroMore bool `json:"zeroMore"`
}

DigestSubject is the subject with a number of items.

type DigestTestInput

type DigestTestInput struct {
	To []string `json:"to" minItems:"1" maxItems:"10"`
}

DigestTestInput sends the next issue as a test.

type DigestThresholds

type DigestThresholds struct {
	Bounce    float64 `json:"bounce"`
	Complaint float64 `json:"complaint"`
	// Scope: route (pause the affected mailbox or sending provider) or campaign.
	Scope string `json:"scope" enum:"route,campaign"`
	// Custom is true when the digest sets its own limits.
	Custom bool `json:"custom"`
}

DigestThresholds are the auto-pause limits issues send with (percent).

type DigestThresholdsInput

type DigestThresholdsInput struct {
	Bounce    float64 `json:"bounce" minimum:"0.1" maximum:"20"`
	Complaint float64 `json:"complaint" minimum:"0.01" maximum:"5"`
	Scope     string  `json:"scope" enum:"route,campaign"`
}

DigestThresholdsInput sets a digest's own auto-pause limits.

type DigestToken

type DigestToken struct {
	Token string `json:"token"`
	Value string `json:"value"`
}

DigestToken is a feed token with its value for the next issue.

type DigestTurnOnInput

type DigestTurnOnInput struct {
	Mode string `json:"mode,omitempty" enum:"auto,draft,"`
}

DigestTurnOnInput turns a digest on (or back on).

type Inserter

type Inserter interface {
	Insert(ctx context.Context, args river.JobArgs, opts *river.InsertOpts) (*rivertype.JobInsertResult, error)
}

Inserter enqueues River jobs (the job client).

type IssueContent

type IssueContent struct {
	Name, Subject, Preheader, MJML, HTML string
	// Items are the posts it shows, in its order.
	Items []BlockItem
	// Basis is what it was built on (digest_issues.basis).
	Basis json.RawMessage
}

IssueContent is an issue's content as a preparation builds it.

func BuildIssue

func BuildIssue(d store.Digest, tpl store.DigestCampaignTemplateRow, posts []BlockItem, number int, sendAt *time.Time, tz string) (IssueContent, error)

BuildIssue builds an issue from a template and its posts, as a preparation does (the demo seeds its sample issues with it), in English.

type IssueData

type IssueData struct {
	FeedTitle string
	FeedURL   string
	Number    int
	// Date is the send day ("Friday 16 October").
	Date  time.Time
	Items []BlockItem
	Loc   *time.Location
	// Lang is the email's language, which writes the dates (emailLang);
	// the zero value writes English.
	Lang i18n.Lang
}

IssueData is what an issue's tokens read.

type IssuePath

type IssuePath struct {
	DigestPath
	IssueID string `path:"issueId" format:"uuid"`
}

IssuePath is the {workspace}/{digestId}/{issueId} of issue operations.

type PrepareArgs

type PrepareArgs struct {
	IssueID uuid.UUID `json:"issue_id" river:"unique"`
}

PrepareArgs prepares an issue.

func (PrepareArgs) InsertOpts

func (PrepareArgs) InsertOpts() river.InsertOpts

InsertOpts implements river.JobArgsWithInsertOpts.

func (PrepareArgs) Kind

func (PrepareArgs) Kind() string

Kind implements river.JobArgs.

type PrepareWorker

type PrepareWorker struct {
	river.WorkerDefaults[PrepareArgs]
	S *Service
}

PrepareWorker prepares an issue.

func (*PrepareWorker) Timeout

Timeout implements river.Worker.

func (*PrepareWorker) Work

func (w *PrepareWorker) Work(ctx context.Context, job *river.Job[PrepareArgs]) error

Work implements river.Worker.

type ReadArgs

type ReadArgs struct {
	DigestID uuid.UUID `json:"digest_id" river:"unique"`
	Via      string    `json:"via"`
}

ReadArgs reads a digest's feed.

func (ReadArgs) InsertOpts

func (ReadArgs) InsertOpts() river.InsertOpts

InsertOpts implements river.JobArgsWithInsertOpts.

func (ReadArgs) Kind

func (ReadArgs) Kind() string

Kind implements river.JobArgs.

type ReadResult

type ReadResult struct {
	OK          bool
	NotModified bool
	Items       int
	New         int
	Err         error
	// Address is the address that was read.
	Address string
}

ReadResult is what a read found.

type ReadWorker

type ReadWorker struct {
	river.WorkerDefaults[ReadArgs]
	S *Service
}

ReadWorker reads a feed.

func (*ReadWorker) Timeout

func (w *ReadWorker) Timeout(*river.Job[ReadArgs]) time.Duration

Timeout implements river.Worker: a read takes 15 seconds at most, plus its images.

func (*ReadWorker) Work

func (w *ReadWorker) Work(ctx context.Context, job *river.Job[ReadArgs]) error

Work implements river.Worker.

type Service

type Service struct {
	Pool  *pgxpool.Pool
	Q     *store.Queries
	Audit *audit.Logger
	Log   *slog.Logger
	Now   func() time.Time
	// Fetcher reads feeds and images through the SSRF guard.
	Fetcher func() *feed.Fetcher
	// Checks, Approvals and Start are Send Readiness, the approvals domain
	// and the sending engine, read at call time (they are built lazily).
	Checks    func() Checks
	Approvals func() Approvals
	Start     func() Starter
	Tests     func() Tester
	URLs      publicurl.Builder
	Jobs      func() Inserter
	// LatestPlugin is the newest WordPress plugin version (the integrations hub).
	LatestPlugin func(ctx context.Context) string
}

Service runs recurring digests.

func (*Service) Check

func (s *Service) Check(ctx context.Context, ws *store.Workspace, p *authz.Principal, digestID uuid.UUID) (DigestCheck, error)

Check runs Send Readiness on the next issue as it would be built now.

func (*Service) Create

Create makes a digest from the type picker: off, in draft mode for a member without campaigns:send, with the Blog digest template, the workspace's default sender and its time zone.

func (*Service) Delete

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

Delete removes a digest that isn't on. Its sent issues stay as campaigns.

func (*Service) Detail

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

Detail is a digest with what its overview and settings show.

func (*Service) FeedPreview

func (s *Service) FeedPreview(ctx context.Context, ws *store.Workspace, id uuid.UUID, limit int) (DigestFeedPreview, error)

FeedPreview is the newest items with their badges, and what the older ones did.

func (*Service) Find

Find reads an address as a feed, or as a page linking to one. It changes nothing: the address is saved with the settings.

func (*Service) History

func (s *Service) History(ctx context.Context, ws *store.Workspace, id uuid.UUID, limit int) (DigestHistory, error)

History is the digest's recent history, newest first: posts that went in or were left out, issues sent or skipped, and the digest turned on or paused (the audit log keeps every settings change).

func (*Service) IssueActor

func (s *Service) IssueActor(ctx context.Context, campaignID uuid.UUID) *audit.Actor

IssueActor is the audit actor of an issue's automatic send (the sending engine asks): the digest on its owner's authority. nil for campaigns that aren't issues.

func (*Service) IssueInfos

func (s *Service) IssueInfos(ctx context.Context, ws *store.Workspace, campaignIDs []uuid.UUID) (DigestIssueInfos, error)

IssueInfos describes the campaigns that are digest issues; the others are left out.

func (*Service) Issues

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

Issues lists a digest's issues, newest first, each compared with the sent issue before it.

func (*Service) List

func (s *Service) List(ctx context.Context, ws *store.Workspace) (DigestList, error)

List returns the workspace's digests for Campaigns › Recurring.

func (*Service) NextAcross

func (s *Service) NextAcross(ctx context.Context, ws *store.Workspace) (*DigestNextAcross, error)

NextAcross finds the workspace's soonest digest issue with a send time.

func (*Service) NextIssueCampaign

func (s *Service) NextIssueCampaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, digestID uuid.UUID, fresh bool) (uuid.UUID, error)

NextIssueCampaign is the campaign of a digest's next issue, for a placement test of it (internal/placement, X14): the one already built for a check or a test while the dialog is open, else built now. fresh builds it again from the feed and the template, as starting a test does, so the copies are the issue as it would go out at that moment.

func (*Service) Pause

Pause stops new issues from being prepared. An issue waiting to go out is skipped (its posts stay new); one that is sending pauses like any send.

func (*Service) PostReported

func (s *Service) PostReported(ctx context.Context, siteID uuid.UUID)

PostReported is the WordPress plugin's report of a published post: the feeds of the digests reading that site are read again at once, so their preview shows the post without waiting for the 30-minute read.

func (*Service) Prepare

func (s *Service) Prepare(ctx context.Context, issueID uuid.UUID) error

Prepare builds an issue from the feed's new posts and checks it: the feed is read again; no new posts skips the issue; a feed that fails is retried every 15 minutes until the send time. The issue is a campaign that runs Send Readiness and the approval rules: Blocked holds it for a person, a matching rule asks the approvers in the owner's name, and in draft mode it becomes a draft someone sends through Review & send.

func (*Service) Preview

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

Preview renders the next issue as it would be built now, for a reader with no first name (fallbacks show). It changes nothing.

func (*Service) Read

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

Read reads a digest's feed now and keeps its items.

func (*Service) Rebuild

func (s *Service) Rebuild(ctx context.Context, ws *store.Workspace, p *authz.Principal, digestID, issueID uuid.UUID) (DigestIssues, error)

Rebuild builds a prepared issue again from the current template and checks it again. Its approval request is checked against the change.

func (*Service) Release

func (s *Service) Release(ctx context.Context, ws *store.Workspace, p *authz.Principal, digestID, issueID uuid.UUID) (DigestIssues, error)

Release puts a held issue back on its way once the block is fixed: it waits for its approval, if the rules ask for one, and goes out at its send time (now, if that passed). Releasing needs campaigns:send.

func (*Service) Render

Render draws the Feed items block and the subject with a preview's posts, for the composer in digest mode.

func (*Service) SendTest

SendTest sends the next issue, as it would be built now, as a test.

func (*Service) Sites

func (s *Service) Sites(ctx context.Context, ws *store.Workspace) (DigestSites, error)

Sites lists the workspace's WordPress sites as feed sources.

func (*Service) Skip

func (s *Service) Skip(ctx context.Context, ws *store.Workspace, p *authz.Principal, digestID, issueID uuid.UUID, in DigestSkipInput) (DigestIssues, error)

Skip skips an issue by hand: nothing goes out, its posts stay new for the next issue, it uses no number.

func (*Service) Tick

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

Tick moves every digest along once (the minute job): it checks owners, reads feeds every 30 minutes, starts preparations, retries failed feeds, rechecks and starts prepared issues at their time, follows issues that are sending and settles those past their late limit.

func (*Service) TurnOn

TurnOn turns a digest on, or back on after a pause. Sending automatically needs campaigns:send; draft mode needs campaigns:edit. Whoever turns it on becomes its owner: issues send on their authority.

func (*Service) Update

Update saves the settings page. Template, feed and schedule changes apply from the next preparation; a prepared issue keeps its content.

type Starter

type Starter interface {
	StartIssue(ctx context.Context, campaignID, ownerID uuid.UUID, rc sending.Recheck) error
	Pause(ctx context.Context, campaignID, by uuid.UUID, reason string) error
}

Starter starts an issue's send through the sending engine, on its owner's authority, with the send-time recheck that was just run.

type Tester

type Tester interface {
	SendTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in campaigns.ComposerTestSend) (campaigns.ComposerTestSendResult, error)
}

Tester sends test emails of a campaign (campaigns.Service.SendTest).

type TickArgs

type TickArgs struct{}

TickArgs is the minute job.

func (TickArgs) InsertOpts

func (TickArgs) InsertOpts() river.InsertOpts

InsertOpts implements river.JobArgsWithInsertOpts.

func (TickArgs) Kind

func (TickArgs) Kind() string

Kind implements river.JobArgs.

type TickWorker

type TickWorker struct {
	river.WorkerDefaults[TickArgs]
	S *Service
}

TickWorker runs the minute job.

func (*TickWorker) Timeout

func (w *TickWorker) Timeout(*river.Job[TickArgs]) time.Duration

Timeout implements river.Worker.

func (*TickWorker) Work

func (w *TickWorker) Work(ctx context.Context, _ *river.Job[TickArgs]) error

Work implements river.Worker.

Directories

Path Synopsis
Package feed reads the feeds recurring digests are built from: RSS 2.0 (and the RSS 1.0 and 0.9x it grew from), Atom 1.0 and JSON Feed 1.0 and 1.1.
Package feed reads the feeds recurring digests are built from: RSS 2.0 (and the RSS 1.0 and 0.9x it grew from), Atom 1.0 and JSON Feed 1.0 and 1.1.

Jump to

Keyboard shortcuts

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