Documentation
¶
Index ¶
- Constants
- Variables
- func MapToDB(author Author) db.AuthorDB
- func SanitizeName(name string) *string
- func ToDBAuthor(author *Author) *db.AuthorDB
- type Author
- type AuthorListEntry
- type AuthorSearchResult
- type ErasureResult
- type Manager
- func (m *Manager) Anonymize(authorId string, dryRun bool) (ErasureResult, error)
- func (m *Manager) AnonymizeAuthor(authorId string) error
- func (m *Manager) CreateAuthor(name *string) (*Author, error)
- func (m *Manager) CreateAuthorIfNotExistsFor(mapper string, name *string) (*Author, error)
- func (m *Manager) GetAuthor(authorId string) (*Author, error)
- func (m *Manager) GetAuthor4Token(token string) (*Author, error)
- func (m *Manager) GetAuthorId(token string) (*Author, error)
- func (m *Manager) GetAuthorName(authorId string) (*string, error)
- func (m *Manager) GetAuthors(authorIds []string) (*[]Author, error)
- func (m *Manager) GetPadsOfAuthor(authorId string) (*[]string, error)
- func (m *Manager) IsErased(authorId string) bool
- func (m *Manager) ListPadsOfAuthor(authorId string) ([]string, error)
- func (m *Manager) SearchAuthors(pattern string, offset, limit int, sortBy string, ...) (AuthorSearchResult, error)
- func (m *Manager) SetAuthorColor(author string, colorId string) error
- func (m *Manager) SetAuthorName(authorId string, authorName string) error
Constants ¶
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 ¶
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 SanitizeName ¶ added in v0.7.0
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
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 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 ¶
func NewManager ¶
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
*
- 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) CreateAuthorIfNotExistsFor ¶ added in v0.7.0
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) GetAuthorName ¶
*
- Returns the name of the author
- @param {String} author The id of the author
func (*Manager) GetAuthors ¶ added in v0.0.4
func (*Manager) GetPadsOfAuthor ¶ added in v0.0.4
func (*Manager) IsErased ¶ added in v0.7.0
IsErased reports whether the author was erased (GDPR Art. 17). Unknown authors are not erased.
func (*Manager) ListPadsOfAuthor ¶
*
- 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.