author

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 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

Index

Constants

View Source
const MaxNameLength = 128

MaxNameLength is the longest author display name, in Unicode code points (etherpad-lite's MAX_AUTHOR_NAME_LENGTH). Names come from unauthenticated socket messages and go to every client that opens a pad, so the server bounds them, not the size limit of a message (GHSA-w4w9-j4c3-hjf6). The pad's name inputs have the same maxlength.

Variables

View Source
var ErrAuthorErased = errors.New("author is erased")

ErrAuthorErased is returned for writes to an erased author: its identity must not come back through a session that was still connected.

Functions

func MapToDB added in v0.0.4

func MapToDB(author Author) db.AuthorDB

func SanitizeName added in v0.7.0

func SanitizeName(name string) *string

SanitizeName trims a display name and cuts it to MaxNameLength code points; a blank name is nil. It is applied when a name is stored and again when one is read, so names stored before the cap are not sent out at their full length.

func ToDBAuthor added in v0.0.2

func ToDBAuthor(author *Author) *db.AuthorDB

Types

type Author

type Author struct {
	Id        string  `json:"id" example:"a.s8oes9dhwrvt0zif"`
	Name      *string `json:"name" example:"John Doe"`
	ColorId   string  `json:"colorId" example:"#ff0000"`
	Token     *string `json:"token,omitempty"`
	Timestamp int64   `json:"timestamp" example:"1704067200000"`
}

Author represents an Etherpad author @Description An author who can collaborate on pads

func MapFromDB added in v0.0.4

func MapFromDB(authorDB db.AuthorDB) Author

func NewRandomAuthor added in v0.0.2

func NewRandomAuthor() *Author

type AuthorListEntry added in v0.7.0

type AuthorListEntry struct {
	AuthorID string   `json:"authorID"`
	Name     *string  `json:"name"`
	ColorID  string   `json:"colorId"`
	Mapper   []string `json:"mapper"`
	LastSeen *int64   `json:"lastSeen"`
	Erased   bool     `json:"erased"`
	ErasedAt *int64   `json:"erasedAt"`
}

AuthorListEntry is one author of the admin's list.

type AuthorSearchResult added in v0.7.0

type AuthorSearchResult struct {
	Total    int               `json:"total"`
	Results  []AuthorListEntry `json:"results"`
	CappedAt *int              `json:"cappedAt"`
}

AuthorSearchResult is a page of the admin's author list.

type ErasureResult added in v0.7.0

type ErasureResult struct {
	AffectedPads            int `json:"affectedPads"`
	RemovedTokenMappings    int `json:"removedTokenMappings"`
	RemovedExternalMappings int `json:"removedExternalMappings"`
	ClearedChatMessages     int `json:"clearedChatMessages"`
}

ErasureResult counts what erasing an author touches (etherpad-lite's anonymizeAuthor counters).

type Manager

type Manager struct {
	Db db.DataStore
}

func NewManager

func NewManager(db db.DataStore) *Manager

func (*Manager) Anonymize added in v0.7.0

func (m *Manager) Anonymize(authorId string, dryRun bool) (ErasureResult, error)

Anonymize erases an author (GDPR Art. 17): the token and the mapper that tie a person to the author are removed, name and colour zeroed, the author's chat messages lose their authorship, and the author is marked erased. Pad text and revisions stay; without the identity record their author ids are opaque. With dryRun nothing changes and the counters tell what would. An unknown author gives zero counters and db.AuthorNotFoundError, so callers can tell. A run that stopped before marking the author erased is completed by the next one. An author already erased is cleaned up again (a session still connected may have written a name, a colour or chat meanwhile); its counters then count only what was left, so a plain repeat gives zeros.

func (*Manager) AnonymizeAuthor added in v0.6.3

func (m *Manager) AnonymizeAuthor(authorId string) error

*

  • AnonymizeAuthor performs GDPR Art. 17 erasure for an author, mirroring the
  • original Etherpad's AuthorManager.anonymizeAuthor (API 1.3.1):
  • - the token binding that links a person to this author id is severed
  • first, so a concurrent token lookup can no longer resolve the author
  • mid-erasure,
  • - the display identity on the author record is zeroed (name -> null,
  • colorId -> 0) while the record itself is kept,
  • - authorship on chat messages the author posted is nulled; the message
  • text itself survives,
  • - pad content, revisions and attribute pools are left intact: changeset
  • references are opaque without the identity record.
  • The operation is idempotent: re-running it leaves the same erased state.
  • Returns db.AuthorNotFoundError if the author does not exist.
  • @param {String} authorId The id of the author

func (*Manager) CreateAuthor

func (m *Manager) CreateAuthor(name *string) (*Author, error)

func (*Manager) CreateAuthorIfNotExistsFor added in v0.7.0

func (m *Manager) CreateAuthorIfNotExistsFor(mapper string, name *string) (*Author, error)

CreateAuthorIfNotExistsFor returns the author of an external id (the mapper, e.g. a user id of an LMS), creating it on first use, and sets its name when one is given (etherpad-lite's createAuthorIfNotExistsFor). Authors created by an older etherpad-go have the mapper as their token; they are found that way and get the mapper recorded.

func (*Manager) GetAuthor

func (m *Manager) GetAuthor(authorId string) (*Author, error)

func (*Manager) GetAuthor4Token

func (m *Manager) GetAuthor4Token(token string) (*Author, error)

func (*Manager) GetAuthorId

func (m *Manager) GetAuthorId(token string) (*Author, error)

func (*Manager) GetAuthorName

func (m *Manager) GetAuthorName(authorId string) (*string, error)

*

  • Returns the name of the author
  • @param {String} author The id of the author

func (*Manager) GetAuthors added in v0.0.4

func (m *Manager) GetAuthors(authorIds []string) (*[]Author, error)

func (*Manager) GetPadsOfAuthor added in v0.0.4

func (m *Manager) GetPadsOfAuthor(authorId string) (*[]string, error)

func (*Manager) IsErased added in v0.7.0

func (m *Manager) IsErased(authorId string) bool

IsErased reports whether the author was erased (GDPR Art. 17). Unknown authors are not erased.

func (*Manager) ListPadsOfAuthor

func (m *Manager) ListPadsOfAuthor(authorId string) ([]string, error)

*

  • Returns an array of all pads this author contributed to
  • @param {String} authorID The id of the author

func (*Manager) SearchAuthors added in v0.7.0

func (m *Manager) SearchAuthors(pattern string, offset, limit int, sortBy string, ascending, includeErased bool) (AuthorSearchResult, error)

SearchAuthors pages through the authors matching pattern in id, name or mapper, erased ones only when asked (etherpad-lite's searchAuthors). At most authorSearchCap are considered; CappedAt says the cap was hit.

func (*Manager) SetAuthorColor

func (m *Manager) SetAuthorColor(author string, colorId string) error

func (*Manager) SetAuthorName

func (m *Manager) SetAuthorName(authorId string, authorName string) error

Jump to

Keyboard shortcuts

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