store

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: BSD-3-Clause Imports: 13 Imported by: 1

Documentation

Overview

Package store manages the message database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	LocalID      string    `yaml:"localID"`
	Hash         string    `yaml:"hash"`
	DeliveryTime time.Time `yaml:"deliveryTime"`
	Message      string    `yaml:"message"`
	Session      int       `yaml:"session"`
	FromAddress  string    `yaml:"fromAddress"`
	FromCallSign string    `yaml:"fromCallSign"`
	FromBBS      string    `yaml:"fromBBS"`
	ToBBS        string    `yaml:"toBBS"`
	Jurisdiction string    `yaml:"jurisdiction"`
	MessageType  string    `yaml:"messageType"`
	Score        int       `yaml:"score"`
	Summary      string    `yaml:"summary"`
	Analysis     string    `yaml:"analysis"`
}

A Message describes a single received message.

type Response

type Response struct {
	LocalID    string    `yaml:"localID"`
	ResponseTo string    `yaml:"responseTo"`
	To         string    `yaml:"to"`
	Subject    string    `yaml:"subject"`
	Body       string    `yaml:"body"`
	SendTime   time.Time `yaml:"sendTime"`
	SenderCall string    `yaml:"senderCall"`
	SenderBBS  string    `yaml:"senderBBS"`
}

A Response is an outgoing message that responds to a received message.

type Retrieval

type Retrieval struct {
	BBS     string    `yaml:"bbs"`
	LastRun time.Time `yaml:"lastRun"`
}

A Retrieval describes a single scheduled retrieval for a session.

type Session

type Session struct {
	ID           int          `yaml:"id"`
	CallSign     string       `yaml:"callSign"`
	Name         string       `yaml:"name"`
	Prefix       string       `yaml:"prefix"`
	Start        time.Time    `yaml:"start"`
	End          time.Time    `yaml:"end"`
	ReportToText []string     `yaml:"-"`
	ReportToHTML []string     `yaml:"-"`
	ToBBSes      []string     `yaml:"toBBSes"`
	DownBBSes    []string     `yaml:"downBBSes"`
	Retrieve     []*Retrieval `yaml:"retrieve"`
	MessageTypes []string     `yaml:"messageTypes"`
	ModelMessage string       `yaml:"modelMessage"`
	Instructions string       `yaml:"instructions"`
	RetrieveAt   string       `yaml:"retrieveAt"`
	Report       string       `yaml:"-"`
	Flags        SessionFlags `yaml:"flags"`

	ModelMsg         message.Message   `yaml:"-"`
	RetrieveInterval interval.Interval `yaml:"-"`
}

A Session defines the parameters of a single session instance.

type SessionFlags

type SessionFlags uint8

SessionFlags is a collection of flags describing a session.

const (
	Running SessionFlags = (1 << iota)
	ExcludeFromWeek
	DontKillMessages
	DontSendResponses
	Imported
	Modified
	ReportToSenders
)

Values for SessionFlags

type Store

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

Store gives access to the database store.

func Open

func Open() (store *Store, err error)

Open opens the database store.

func (*Store) CreateSession

func (s *Store) CreateSession(session *Session)

CreateSession creates a new session.

func (*Store) DeleteModelImages

func (s *Store) DeleteModelImages(sid int)

DeleteModelImages removes all model images for the specified session.

func (*Store) DeleteSession

func (s *Store) DeleteSession(session *Session)

DeleteSession deletes a session.

func (*Store) ExistSessions

func (s *Store) ExistSessions(start, end time.Time) bool

ExistSessions returns whether any sessions exist in the specified time range (inclusive start, exclusive end).

func (*Store) GetMessage

func (st *Store) GetMessage(localID string) *Message

GetMessage returns the message with the specified local ID, or nil if there is none.

func (*Store) GetMessageByHash

func (st *Store) GetMessageByHash(hash string) *Message

GetMessageByHash returns the message with the specified hash, or nil if there is none.

func (*Store) GetResponses

func (st *Store) GetResponses(to string) (responses []*Response)

GetResponses retrieves the responses for the specified message.

func (*Store) GetRunningSessions

func (s *Store) GetRunningSessions() (list []*Session)

GetRunningSessions returns the (unordered) list of all running sessions.

func (*Store) GetSession

func (s *Store) GetSession(id int) *Session

GetSession returns the session with the specified ID, or nil if there is none.

func (*Store) GetSessionMessages

func (st *Store) GetSessionMessages(sessionID int) (messages []*Message)

GetSessionMessages returns the set of messages received for the session, in the order they were delivered to the BBS at which they were received.

func (*Store) GetSessions

func (s *Store) GetSessions(start, end time.Time) (list []*Session)

GetSessions returns the set of sessions that end during the specified time range (inclusive start, exclusive end). The sessions are sorted by end time, then by call sign.

func (*Store) HasMessageHash

func (st *Store) HasMessageHash(hash string) (id string)

HasMessageHash looks to see whether the database already contains a message with the specified hash. If so, it returns the ID of that message; if not, it returns an empty string.

func (*Store) ModelImage

func (s *Store) ModelImage(sid int, pnum int) (fh *os.File)

ModelImage returns an open file handle to the specified model image page number, or nil if there is no such image. Model image page numbers start at 1. It is the caller's responsibility to close the handle.

func (*Store) ModelImageCount

func (s *Store) ModelImageCount(sid int) (count int)

ModelImageCount returns the number of model images associated with the session. The images use 1-based numbering, so they are numbered 1 through the return value of this function, inclusive.

func (*Store) NextMessageID

func (st *Store) NextMessageID(prefix string) string

NextMessageID returns the next message ID in the sequence with the specified prefix.

func (*Store) SaveMessage

func (st *Store) SaveMessage(m *Message)

SaveMessage saves a message to the database.

func (*Store) SaveModelImage

func (s *Store) SaveModelImage(sid int, pnum int, name string, body io.Reader)

SaveModelImage saves the specified model image for the specified session.

func (*Store) SaveResponse

func (st *Store) SaveResponse(r *Response)

SaveResponse saves an outgoing response to the database.

func (*Store) SessionHasMessages

func (st *Store) SessionHasMessages(sessionID int) bool

SessionHasMessages returns whether there are any messages stored for the specified session.

func (*Store) UpdateSession

func (s *Store) UpdateSession(session *Session)

UpdateSession updates an existing session.

Jump to

Keyboard shortcuts

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