paidaccess

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package paidaccess says who has paid access (Earn, design expansion X16) to the domains that choose recipients and content: paid-only campaigns ("Who on this list"), paid-only blocks (Visibility · Paid access), paid tokens and the contacts table. It reads Earn's tables the way segments read scores; internal/earn writes them.

A contact has paid access while a live subscription, complimentary grant or gift hasn't ended and is trialing, active, complimentary or a gift, or past due while Stripe retries (unless the access rule paused it). A higher tier includes a lower tier's paid content: "Insider and above" means a tier ranked at least Insider's. Test paid members never count.

Index

Constants

View Source
const (
	Everyone = ""
	Free     = "free" // free subscribers only (no paid access at all)
)

Who on a campaign's lists receives it.

View Source
const (
	UpgradeURL = "upgrade_url"
	ManageURL  = "manage_subscription_url"
)

The reader's personal Earn links: internal/earn fills them in per reader at send time, like the unsubscribe link, and never through click tracking; the composer's checks and preview treat them as such.

Variables

This section is empty.

Functions

func Facts

func Facts(ctx context.Context, q *store.Queries, wsID uuid.UUID, ids []uuid.UUID) (map[uuid.UUID]Fact, error)

Facts reads some contacts' paid access; contacts without any are left out.

func IsReaderLink(key string) bool

IsReaderLink reports whether a Liquid variable is one of the reader's personal Earn links.

func MinRank

func MinRank(ctx context.Context, q *store.Queries, wsID uuid.UUID, tier string) (int, error)

MinRank is the lowest access rank a paid audience or condition keeps: 1 for any paid tier, the tier's rank for "tier and above", and a rank no tier has when the tier was deleted.

func ShortName

func ShortName(name string, lists []string) string

ShortName is how readers name a tier: its name without the list it belongs to ("Weekly Digest Insider" on Weekly Digest is "Insider").

Types

type Audience

type Audience struct {
	Who  string
	Tier string
}

Audience is the paid part of campaigns.audience: who on the lists gets the campaign and, for paid members, the lowest tier (empty: any).

func Parse

func Parse(raw json.RawMessage) Audience

Parse reads the paid part of a stored audience (both key styles).

func (Audience) Set

func (a Audience) Set() bool

Set reports whether the audience keeps only paid members or only free subscribers.

type Fact

type Fact struct {
	Status      string // trialing, active, past_due, complimentary, gift
	Kind        string // stripe, complimentary, gift
	TierID      uuid.UUID
	Tier        string
	Rank        int
	Period      string // month, year, or empty for grants and gifts
	AmountCents int64
	Currency    string
	Discount    json.RawMessage
	StartedAt   time.Time
	// RenewsAt is the next renewal while it renews; EndsAt is when access
	// ends (a scheduled cancellation, a trial without a card, a grant's or
	// a gift's end).
	RenewsAt *time.Time
	EndsAt   *time.Time
	TrialEnd *time.Time
}

Fact is a contact's paid access, as personalization and conditions read it: the highest tier's subscription, grant or gift.

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper decides who a paid audience keeps, read once per count or send. A nil Keeper keeps everyone.

func Load

func Load(ctx context.Context, q *store.Queries, wsID uuid.UUID, a Audience) (*Keeper, error)

Load reads who an audience keeps.

func (*Keeper) Keeps

func (k *Keeper) Keeps(id uuid.UUID) bool

Keeps reports whether the audience keeps a contact.

func (*Keeper) Member

func (k *Keeper) Member(id uuid.UUID) (Member, bool)

Member is a kept paid member's access (false for free subscribers).

func (*Keeper) Who

func (k *Keeper) Who() string

Who is the audience's choice (Paid or Free).

type ListCounts

type ListCounts struct {
	Everyone int64
	Paid     int64
	Free     int64
}

ListCounts are the recipients of lists split by paid access.

func CountLists

func CountLists(ctx context.Context, q *store.Queries, wsID uuid.UUID, lists, exclude []uuid.UUID, tier string) (ListCounts, error)

CountLists counts the recipients of lists (minus excluded lists and suppressions) as the composer does: everyone, paid members at the tier and above, and free subscribers.

type Member

type Member struct {
	Status string // trialing, active, past_due, complimentary, gift
	Kind   string // stripe, complimentary, gift
	Rank   int
}

Member is a contact's paid access as an audience reads it.

type Tier

type Tier struct {
	ID   uuid.UUID
	Name string
	// Short is how readers name it: the name without its list's
	// ("Weekly Digest Insider" on Weekly Digest is "Insider").
	Short string
	Rank  int
	// Top is the highest tier: "Founding member" rather than "Founding
	// member and above".
	Top bool
}

Tier is a tier in access order, for the pickers.

func Tiers

func Tiers(ctx context.Context, q *store.Queries, wsID uuid.UUID) ([]Tier, error)

Tiers are the workspace's tiers (archived ones left out), lowest first.

Jump to

Keyboard shortcuts

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