envelope

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: BSD-3-Clause Imports: 13 Imported by: 8

Documentation

Overview

Package envelope contains all the knowledge about how message content (forms, plain text messages, receipts, etc.) are wrapped in envelopes for sending, receiving, and storage.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPlainTextBody = errors.New("message has no plain text body content")

ErrNoPlainTextBody is raised when a message being parsed has no plain text body content.

Functions

This section is empty.

Types

type Address

type Address struct {
	Name    string
	Address string
}

Address is an address that can appear in the header of a message. It consists of an optional name comment followed by an xxx or xxx@yyy address. It is roughly similar to mail.Address, but does not require the Address part to contain a domain.

func ParseAddress

func ParseAddress(s string) (*Address, error)

func ParseAddressList

func ParseAddressList(s string) (addrs []*Address, err error)

func (*Address) String

func (addr *Address) String() string

type Envelope

type Envelope struct {
	// ReceivedBBS is the name of the BBS from which the message was
	// retrieved.  It is set only for received messages.
	ReceivedBBS string
	// ReceivedArea is the bulletin area from which the message was
	// retrieved.  It is set only for received bulletin messages.
	ReceivedArea string
	// ReceivedDate is the date/time at which the message was retrieved from
	// JNOS.  It is set only for received messages.
	ReceivedDate time.Time
	// Autoresponse is a flag indicating that the received message was an
	// autoresponse message.  This is a non-persistent field, set only on
	// messages retrieved from JNOS (as opposed to local storage).
	Autoresponse bool
	// ReturnAddr is the return address for the message.  This is a
	// non-persistent field, set only for messages retrieved from JNOS (as
	// opposed to local storage), and not necessarily all of those.
	ReturnAddr string
	// BBSReceivedDate is the date/time at which the message was received by
	// the BBS from which we retrieved it.  This is a non-persistent field,
	// set only on messages retrieved from JNOS (as opposed to local
	// storage).
	BBSReceivedDate time.Time
	// From is a comma-separated list of addresses of senders of the
	// message, from the "From:" header.  In the vast majority of cases,
	// there's only one address on the list.
	From string
	// To is a comma-separated list of destination addresses for the
	// message, from the "To:", "Cc:", and "Bcc:" headers (we don't
	// distinguish).
	To string
	// Date is the date/time at which the message was sent, from the Date:
	// header.  It is set only for messages that have gone over the air
	// (received or transmitted).
	Date time.Time
	// SubjectLine is the subject line of the message.
	SubjectLine string
	// NotPlainText is a flag indicating that the received message was not
	// in plain text encoding.  This is a non-persistent field, set only for
	// messages retrieved from JNOS (as opposed to local storage).
	NotPlainText bool
	// OutpostUrgent is a flag indicating that Outpost considers this
	// message to be urgent.  (In Santa Clara County this normally
	// correlates with an "IMMEDIATE" handling order.)
	OutpostUrgent bool
	// RequestDeliveryReceipt is an Outpost flag indicating that the
	// recipient should send a delivery receipt for the message to its
	// sender.
	RequestDeliveryReceipt bool
	// RequestReadReceipt is an Outpost flag indicating that the recipient
	// should send a read receipt for the message to its sender, when the
	// message is first read by a human.
	RequestReadReceipt bool
	// ReadyToSend is a flag indicating that the (outgoing, untransmitted)
	// message is ready to be sent.  When false, the message is a draft.
	// This field is ignored for received or transmitted messages.
	ReadyToSend bool
	// Bulletin is a flag indicating that this message is a bulletin (either
	// incoming or outgoing).
	Bulletin bool
}

An Envelope structure contains the envelope of a packet message.

func ParseRetrieved

func ParseRetrieved(retrieved, bbs, area string) (_ *Envelope, body string, err error)

ParseRetrieved parses the supplied string as a message that was just retrieved from the specified JNOS BBS. If it is a bulletin, area should be set to the bulletin area from which it was retrieved; otherwise, area should be empty.

func ParseSaved

func ParseSaved(saved string) (_ *Envelope, body string, err error)

ParseSaved parses the supplied string as a saved message (which could be either incoming or outgoing).

func (*Envelope) IsFinal

func (env *Envelope) IsFinal() bool

IsFinal returns whether the message has gone over the air (either received or transmitted). Note that even if this returns true, the message can still be changed in some ways (e.g. to add a destination message number when a delivery receipt arrives).

func (*Envelope) IsReceived

func (env *Envelope) IsReceived() bool

IsReceived returns whether the message was received (as opposed to sent or pending send).

func (*Envelope) RenderBody

func (env *Envelope) RenderBody(body string) string

RenderBody renders just the body part of the message according to the parameters in the envelope.

func (*Envelope) RenderSaved

func (env *Envelope) RenderSaved(body string) string

RenderSaved renders the supplied envelope and body, in a form suitable for later reading by ParseSaved. Note that a few envelope fields are not preserved, as noted in their documentation.

Jump to

Keyboard shortcuts

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