Help us shape the future of Go! Take the 2026 Go Developer Survey

contactexport

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package contactexport is the subject-access Data export of one Contact (GDPR Art. 15/20, ADR 0021): a streamed JSON document holding the Contact, its Tags, Visitors, all Events, the Unsubscribe/Suppression/Confirmation rows for its Destinations and the OutboundMessage / BroadcastRecipient delivery metadata. Rendered message bodies are never part of it (no entity read here carries one). Each row is projected onto the contract's typed ContactExportDocument members by a Mapper, never encoded as the stored entity. Large collections are read in keyset pages and written straight to the writer, so the document is never buffered whole.

Index

Constants

This section is empty.

Variables

View Source
var ErrIdentifier = errors.New("contactexport: exactly one of id or email is required")

ErrIdentifier means the request named neither or both of id and email.

View Source
var ErrNotFound = errors.New("contactexport: contact not found")

ErrNotFound means no Contact in the Workspace matches the identifier.

Functions

func Filename

func Filename(c *ent.Contact) string

Filename is the suggested download name of c's export.

func Find

func Find(ctx context.Context, s *ent.Scoped, id *int64, email *string) (*ent.Contact, error)

Find resolves the Contact to export by exactly one of its id or email, inside the Workspace of s: another Workspace's Contact is not found. Both surfaces map its two errors (ErrIdentifier: bad request; ErrNotFound) the same way.

func Open

func Open(ctx context.Context, s *ent.Scoped, m Mapper, c *ent.Contact) io.Reader

Open starts the export of c in the background and returns the stream to hand to the HTTP response: the document is produced as the response is read. The producer ends with the request's context, so an abandoned download cannot leak it.

func Ref

func Ref[T ~string](v T, ok bool) *string

Ref is the optional string of a query parameter read as "(value, present)": nil when absent. It lets a handler pass its generated Opt parameters straight to Find.

func Stream

func Stream(ctx context.Context, s *ent.Scoped, m Mapper, w io.Writer, c *ent.Contact) error

Stream writes the export of c to w as one JSON object. The Contact and every member are read through s, so nothing outside the Workspace can appear.

Types

type Mapper

type Mapper interface {
	Contact(row *ent.Contact) json.Marshaler
	Tag(row *ent.Tag) json.Marshaler
	Visitor(row *ent.Visitor) json.Marshaler
	Event(row *ent.Event) json.Marshaler
	Unsubscribe(row *ent.Unsubscribe) json.Marshaler
	Suppression(row *ent.Suppression) json.Marshaler
	Confirmation(row *ent.Confirmation) json.Marshaler
	OutboundMessage(row *ent.OutboundMessage) json.Marshaler
	BroadcastRecipient(row *ent.BroadcastRecipient) json.Marshaler
}

Mapper projects stored rows onto the members of the surface's generated ContactExportDocument. Each surface (site, external) generates its own copy of those types from the shared TypeSpec model, so a Mapper hands back each member as a json.Marshaler and the document is assembled here without knowing which surface it serves. Stored rows are never encoded directly: the contract, not the ent JSON tags, decides what a person sees.

Jump to

Keyboard shortcuts

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