draft

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const QuoteWrapperClass = "history-quote-wrapper"

QuoteWrapperClass is the CSS class name used by Lark's mail composer for reply/forward quote blocks. Both +reply and +forward wrap the quoted original message in a <div> with this class. Exported so that mail_quote.go (the generator) and projection.go (the detector) share a single source of truth.

Variables

This section is empty.

Functions

func Apply

func Apply(snapshot *DraftSnapshot, patch Patch) error

func CreateWithRaw

func CreateWithRaw(runtime *common.RuntimeContext, mailboxID, rawEML string) (string, error)

func MustJSON

func MustJSON(v interface{}) string

func Send

func Send(runtime *common.RuntimeContext, mailboxID, draftID string) (map[string]interface{}, error)

func Serialize

func Serialize(snapshot *DraftSnapshot) (string, error)

func UpdateWithRaw

func UpdateWithRaw(runtime *common.RuntimeContext, mailboxID, draftID, rawEML string) error

Types

type Address

type Address struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"address"`
}

func (Address) String

func (a Address) String() string

type AttachmentTarget

type AttachmentTarget struct {
	PartID string `json:"part_id,omitempty"`
	CID    string `json:"cid,omitempty"`
}

type DraftProjection

type DraftProjection struct {
	Subject            string        `json:"subject"`
	To                 []Address     `json:"to,omitempty"`
	Cc                 []Address     `json:"cc,omitempty"`
	Bcc                []Address     `json:"bcc,omitempty"`
	ReplyTo            []Address     `json:"reply_to,omitempty"`
	InReplyTo          string        `json:"in_reply_to,omitempty"`
	References         string        `json:"references,omitempty"`
	BodyText           string        `json:"body_text,omitempty"`
	BodyHTMLSummary    string        `json:"body_html_summary,omitempty"`
	HasQuotedContent   bool          `json:"has_quoted_content,omitempty"`
	AttachmentsSummary []PartSummary `json:"attachments_summary,omitempty"`
	InlineSummary      []PartSummary `json:"inline_summary,omitempty"`
	Warnings           []string      `json:"warnings,omitempty"`
}

func Project

func Project(snapshot *DraftSnapshot) DraftProjection

type DraftRaw

type DraftRaw struct {
	DraftID string
	RawEML  string
}

func GetRaw

func GetRaw(runtime *common.RuntimeContext, mailboxID, draftID string) (DraftRaw, error)

type DraftSnapshot

type DraftSnapshot struct {
	DraftID string
	Headers []Header
	Body    *Part

	Subject    string
	From       []Address
	To         []Address
	Cc         []Address
	Bcc        []Address
	ReplyTo    []Address
	MessageID  string
	InReplyTo  string
	References string

	PrimaryTextPartID string
	PrimaryHTMLPartID string
}

func Parse

func Parse(raw DraftRaw) (*DraftSnapshot, error)
type Header struct {
	Name  string
	Value string
}

type Part

type Part struct {
	PartID string

	Headers               []Header
	MediaType             string
	MediaParams           map[string]string
	ContentDisposition    string
	ContentDispositionArg map[string]string
	ContentID             string
	TransferEncoding      string

	Children []*Part
	Body     []byte

	Preamble []byte
	Epilogue []byte

	RawEntity []byte
	Dirty     bool

	// EncodingProblem is set when the part's body could not be decoded as
	// declared (e.g. malformed base64, bad charset, unparseable Content-Type).
	// The part still contains usable data (raw bytes or fallback decode) and
	// can round-trip through RawEntity, but callers should treat Body as
	// potentially degraded.
	EncodingProblem bool
}

func (*Part) Clone

func (p *Part) Clone() *Part

func (*Part) FileName

func (p *Part) FileName() string

func (*Part) IsMultipart

func (p *Part) IsMultipart() bool

type PartSummary

type PartSummary struct {
	PartID      string `json:"part_id"`
	FileName    string `json:"filename,omitempty"`
	ContentType string `json:"content_type,omitempty"`
	Disposition string `json:"disposition,omitempty"`
	CID         string `json:"cid,omitempty"`
}

type Patch

type Patch struct {
	Ops     []PatchOp    `json:"ops"`
	Options PatchOptions `json:"options,omitempty"`
}

func (Patch) Summary

func (p Patch) Summary() map[string]interface{}

func (Patch) Validate

func (p Patch) Validate() error

type PatchOp

type PatchOp struct {
	Op          string           `json:"op"`
	Value       string           `json:"value,omitempty"`
	Field       string           `json:"field,omitempty"`
	Address     string           `json:"address,omitempty"`
	Name        string           `json:"name,omitempty"`
	Addresses   []Address        `json:"addresses,omitempty"`
	BodyKind    string           `json:"body_kind,omitempty"`
	Selector    string           `json:"selector,omitempty"`
	Path        string           `json:"path,omitempty"`
	CID         string           `json:"cid,omitempty"`
	FileName    string           `json:"filename,omitempty"`
	ContentType string           `json:"content_type,omitempty"`
	Target      AttachmentTarget `json:"target,omitempty"`
}

func (PatchOp) Validate

func (op PatchOp) Validate() error

type PatchOptions

type PatchOptions struct {
	RewriteEntireDraft        bool `json:"rewrite_entire_draft,omitempty"`
	AllowProtectedHeaderEdits bool `json:"allow_protected_header_edits,omitempty"`
}

Jump to

Keyboard shortcuts

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