Documentation ¶
Overview ¶
Package incident manages collections of related messages.
An incident is stored on disk as a directory of message files; each separate incident is a separate directory. Specifically, package incident always works with the message files in the current working directory of the calling program.
Within the directory, each non-receipt message is stored in a file called «LMI».txt, where «LMI» is the local message ID for the message. If any remote message IDs for the message are known, symbolic links name «RMI».txt point to «LMI».txt. (There may be multiple remote message IDs if the message was sent to multiple recipients.)
Messages are automatically rendered in PDF format if the message type supports it and PDF rendering is built into the program; the PDF version is stored in «LMI».pdf, with possible symbolic link from «RMI».pdf.
Delivery and read receipts are stored in «LMI».DR#.txt and «LMI».RR#.txt, respectively, where '#' is either absent or a serial number starting with 2. (Multiple receipts may be received for a message if it was sent to multiple recipients.) There are no «RMI» symbolic links for those.
On request, package incident can also generate an ICS-309 message log for the messages in the directory. This is stored in CSV format in ics309.csv, and if PDF rendering is built into the program, it is rendered in PDF format in ics309.pdf as well. Both files are automatically removed when any message is changed, so that the directory does not contain a stale log.
Index ¶
- Variables
- func AllLMIs() (lmis []string, err error)
- func GenerateICS309(header *ICS309Header) (err error)
- func LMIForRMI(rmi string) string
- func MessageExists(lmi string) bool
- func ReadMessage(lmi string) (env *envelope.Envelope, msg message.Message, err error)
- func ReadReceipt(lmi, rcpt string) (env *envelope.Envelope, msg message.Message, err error)
- func ReceiveMessage(raw, bbs, area, msgid, opcall, opname string) (lmi string, env *envelope.Envelope, msg message.Message, ...)
- func RemoveICS309s()
- func RemoveMessage(lmi string)
- func SaveMessage(lmi, rmi string, env *envelope.Envelope, msg message.Message, ...) (err error)
- func SaveReceipt(lmi string, env *envelope.Envelope, msg message.Message) (err error)
- func SeqToLMI(seq int, remote bool) (lmis []string, err error)
- func UniqueMessageID(id string) string
- type DeliveryInfo
- type ICS309Header
- type Warning
Constants ¶
This section is empty.
Variables ¶
var MsgIDRE = regexp.MustCompile(`^([0-9][A-Z]{2}|[A-Z][A-Z0-9]{2})-([1-9][0-9]{2,}|0[1-9][0-9]|00[1-9])([A-Z]?)$`)
MsgIDRE is a regular expression matching a valid message ID. Its substrings are the three-character prefix, the three-or-more-digit sequence number, and the optional suffix character.
Functions ¶
func AllLMIs ¶
AllLMIs returns a list of local message IDs of all messages in the directory. The list is in chronological order. An error is returned only if the directory cannot be read.
func GenerateICS309 ¶
func GenerateICS309(header *ICS309Header) (err error)
GenerateICS309 generates an ICS-309 communications log covering all of the messages in the directory. The log is generated in CSV format (ics309.csv), and if PDF rendering support is built into the program, it is also generated in PDF format (ics309.pdf). GenerateICS309 returns an error if the directory could not be read or the files could not be written. Note that the generated files are removed by any call to SaveMessage or SaveReceipt, since they could be stale.
func LMIForRMI ¶
LMIForRMI returns the LMI for the message with the given RMI, if any. It returns "" if the RMI doesn't exist.
func MessageExists ¶
MessageExists returns true if a message exists with the specified LMI.
func ReadMessage ¶
ReadMessage reads a message from the incident directory and returns it.
func ReadReceipt ¶ added in v1.8.3
ReadReceipt reads a receipt for a message. rcpt must be "DR#" or "RR#".
func ReceiveMessage ¶
func ReceiveMessage(raw, bbs, area, msgid, opcall, opname string) ( lmi string, env *envelope.Envelope, msg message.Message, oenv *envelope.Envelope, omsg message.Message, err error, )
ReceiveMessage takes a raw message received from JNOS and saves it in the incident. "bbs" and "area" are the names of the BBS from which the message was retrieved and, if the message is a bulletin, the bulletin area from which it was retrieved. "msgid" is the message ID pattern; a unique ID will be given to the new message using this pattern if it needs one. "opcall" and "opname" are the operator call sign and name to put into the received message.
If the received message is a human-originated message, it will be returned as "lmi", "env", and "msg". If a delivery receipt should be sent for it, the receipt is returned as "oenv" and "omsg". (Note that the delivery receipt has not been saved; the caller should do that after sending it.)
If the received message is a receipt, it will be returned as "env" and "msg". If the receipt can be matched against a previously sent message in the incident, that previously sent message is returned as "lmi", "oenv", and "omsg" are the message for which it is a receipt.
If the received message has an error, "err" will be set and the other return values will be zero. If the received message has a warning, "err" will be set to a Warning value, and the other return values will be set as above.
func RemoveICS309s ¶
func RemoveICS309s()
RemoveICS309s removes generated ICS-309 communication log files.
func RemoveMessage ¶
func RemoveMessage(lmi string)
RemoveMessage removes the message with the specified LMI.
func SaveMessage ¶
func SaveMessage(lmi, rmi string, env *envelope.Envelope, msg message.Message, fast, rawsubj bool) (err error)
SaveMessage saves a (non-receipt) message to the incident directory, overwriting any previous message stored with the same LMI. If rmi is not empty, an RMI symlink is created. (Existing RMI symlinks are not disturbed.) If fast is true, PDFs are not generated even when possible; stale PDFs are removed. If rawsubj is true, the envelope Subject: line is left unchanged rather than being regenerated based on the message contents.
func SaveReceipt ¶
SaveReceipt saves a receipt message to the incident directory, with a unique sequence number to avoid overwriting other receipts for the same message.
func SeqToLMI ¶
SeqToLMI takes a sequence number and expands it to a list of existing message LMIs with that sequence number. If remote is true, the LMIs of messages whose RMI has the requested sequence number are also included. The LMIs are returned in unspecified order. An error is returned only if the directory cannot be read.
func UniqueMessageID ¶
UniqueMessageID returns the provided message ID if there is no existing message in the directory with that ID (local or remote). Otherwise, it increments the sequence number until the message ID is unused, and returns the result.
Types ¶
type DeliveryInfo ¶ added in v1.9.0
type DeliveryInfo struct { // Recipient is the address of the recipient to which the message was // addressed. Display names are removed and domains are fleshed out. Recipient string // DeliveredTime is the date and time when the message was delivered to // the recipient, as described in the delivery receipt they sent back. // (It is a string because there is no standard time formatting for this // delivery receipt field.) It is empty if no delivery receipt has been // received from this recipient. DeliveredTime string // RemoteMessageID is the message ID assigned to the message by the // recipient. It is empty if no delivery receipt has been received from // this recipient. RemoteMessageID string // contains filtered or unexported fields }
A DeliveryInfo structure describes the delivery of a message to a recipient.
func Deliveries ¶ added in v1.9.0
func Deliveries(lmi string) (delivs []*DeliveryInfo, err error)
Deliveries returns the delivery information for an outgoing message. One DeliveryInfo structure is returned for each distinct To/Cc/Bcc address in the message. (If there are none, a single structure is returned.) An error is returned only if files cannot be read or decoded.
type ICS309Header ¶
type ICS309Header struct { IncidentName string ActivationNum string OpStartDate string OpStartTime string OpEndDate string OpEndTime string OpCall string OpName string TacCall string TacName string }
An ICS309Header structure contains all of the information needed for the header of an ICS-309 communications log.