documents

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package documents keeps the Markdown documents a bot (the facilitator of the kunveno-facilitator add-on) prepares during a meeting: per room and meeting, each under an id the bot chooses, with its title, revision and update time. A document is kept for keep after its last update.

Index

Constants

View Source
const (
	MaxBody       = 512 << 10 // bytes of Markdown
	MaxTitle      = 120       // characters after trim
	MaxPerMeeting = 20
)

Limits of the bot contract.

Variables

View Source
var (
	ErrBadSlug    = errors.New("documents: bad room slug")
	ErrBadID      = errors.New("documents: bad document id")
	ErrBadTitle   = errors.New("documents: bad title")
	ErrTooMany    = errors.New("documents: the meeting already has the most documents")
	ErrNoDocument = errors.New("documents: no such document")
)

Functions

func CleanTitle

func CleanTitle(s string) (string, bool)

CleanTitle collapses every whitespace run of s to one space and trims the ends; false when the result is not valid UTF-8, holds a control character or is not 1..MaxTitle characters long.

func FileName

func FileName(slug string, start time.Time, title, id string, loc *time.Location) string

FileName is a download's name: the room, the meeting's start and the title, letters and digits kept and every other run turned into one hyphen, at most 60 characters of it; the id when nothing of the title is left.

func ValidID

func ValidID(id string) bool

ValidID reports whether id may name a document.

Types

type Gone

type Gone struct {
	Slug    string
	Meeting int64
}

Gone names a meeting that lost a document in the sweep.

type Info

type Info struct {
	ID      string    `json:"id"`
	Title   string    `json:"title"`
	Rev     int       `json:"rev"`
	Created time.Time `json:"created"` // first stored; orders the list
	Updated time.Time `json:"updated"`
}

Info describes one stored document.

func (Info) Until

func (i Info) Until(keep time.Duration) time.Time

Until is when the document expires under keep.

type Store

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

Store keeps dir/<slug>/<meeting>/<id>.md and, per meeting, index.json with the documents' Info. Safe for concurrent use.

func Open

func Open(dir string, keep time.Duration, now func() time.Time) (*Store, error)

Open reads the indexes in dir (a missing dir holds none). An index that cannot be read is logged and skipped, left on disk; only a failure to list dir is an error.

func (*Store) Bytes

func (s *Store) Bytes() int64

Bytes is how much the documents take on disk.

func (*Store) Delete

func (s *Store) Delete(slug string, meeting int64, id string) error

Delete removes one document at a person's request; ErrNoDocument when it is not there or has expired.

func (*Store) Has

func (s *Store) Has(slug string, meeting int64) bool

Has reports whether the meeting keeps a document.

func (*Store) Keep

func (s *Store) Keep() time.Duration

Keep is how long a document stays after its last update.

func (*Store) List

func (s *Store) List(slug string, meeting int64) []Info

List returns the meeting's documents that have not expired, in the order first stored.

func (*Store) Load

func (s *Store) Load(slug string, meeting int64, id string) (Info, []byte, error)

Load reads one document; ErrNoDocument when it is not there or has expired.

func (*Store) Meetings

func (s *Store) Meetings(slug string) []int64

Meetings lists the starts of the room's meetings that keep a document, newest first.

func (*Store) Put

func (s *Store) Put(slug string, meeting int64, id, title string, body []byte) (Info, error)

Put stores body as the document id of the room's meeting. A new id is refused with ErrTooMany once the meeting has MaxPerMeeting documents; an id already stored is replaced, its revision grows by one and its title becomes title.

func (*Store) Remove

func (s *Store) Remove(slug string) error

Remove deletes everything the room keeps, for a deleted room. The room is forgotten even when its directory cannot be removed (the error is returned).

func (*Store) Sweep

func (s *Store) Sweep() []Gone

Sweep deletes expired documents and returns the meetings that lost one, sorted.

Jump to

Keyboard shortcuts

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