documents

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package documents implements a service for managing documents.

Index

Constants

View Source
const (
	ErrInvalidPath = Error("invalid path")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentView

type DocumentView struct {
	ID           string    `jsonapi:"primary,document"`   // singular when sending a payload
	OwnerHandle  string    `jsonapi:"attr,owner"`         // handle of user that owns this document
	UserHandle   string    `jsonapi:"attr,created-by"`    // handle of user for this document
	GameId       string    `jsonapi:"attr,game-id"`       // game for this document
	ClanNo       string    `jsonapi:"attr,clan"`          // clan for this document
	DocumentName string    `jsonapi:"attr,document-name"` // untainted name of document
	DocumentType string    `jsonapi:"attr,document-type"` // for categorizing on the dashboards
	CanRead      bool      `jsonapi:"attr,can-read"`
	CanWrite     bool      `jsonapi:"attr,can-write"`
	CanDelete    bool      `jsonapi:"attr,can-delete"`
	CanShare     bool      `jsonapi:"attr,can-share"`
	IsShared     bool      `jsonapi:"attr,is-shared"`
	CreatedAt    time.Time `jsonapi:"attr,created-at,iso8601"`
	UpdatedAt    time.Time `jsonapi:"attr,updated-at,iso8601"`
}

DocumentView is the JSON:API view for a document.

func (d *DocumentView) JSONAPILinks() *jsonapi.Links

JSONAPILinks implements the jsonapi.Linkable interface for document-links

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type Service

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

Service provides document management operations.

func New

func New(db *sqlite.DB, authzSvc *authz.Service, usersSvc *users.Service) *Service

func (*Service) CreateDocument

func (s *Service) CreateDocument(actor *domains.Actor, clan *domains.Clan, doc *domains.Document) (domains.ID, error)

CreateDocument creates a document.

Actor is the user/service requesting the creation. Owner is the user that will own the new document.

func (*Service) DeleteDocument

func (s *Service) DeleteDocument(actor *domains.Actor, documentId domains.ID) error

DeleteDocument will return nil if the document doesn't exist. Returns an error if the actor is not authorized to delete it.

func (*Service) FindClanByGameAndNumber

func (s *Service) FindClanByGameAndNumber(gameID string, clanNo int) (*domains.Clan, error)

func (*Service) GetAllDocumentsForUserAcrossGames

func (s *Service) GetAllDocumentsForUserAcrossGames(actor *domains.Actor, docType domains.DocumentType, pageNumber, pageSize int) ([]*DocumentView, error)

GetAllDocumentsForUserAcrossGames returns an unsorted list of documents that the actor has permissions to view. Returns an empty list (not a nil list) if there are no documents.

func (*Service) GetDocument

func (s *Service) GetDocument(actor *domains.Actor, documentId domains.ID) (*DocumentView, error)

GetDocument returns nil, nil if no data found

func (*Service) GetDocumentContents

func (s *Service) GetDocumentContents(actor *domains.Actor, documentId domains.ID) (*domains.Document, error)

GetDocumentContents returns nil, nil if no data found

func (*Service) LoadDocxFromFS

func (s *Service) LoadDocxFromFS(actor *domains.Actor, clan *domains.Clan, path, name string, canDelete, canRead, canShare, canWrite bool) (domains.ID, error)

LoadDocxFromFS loads the file, creates a Document, and returns the document ID.

func (*Service) LoadDocxFromRequest

func (s *Service) LoadDocxFromRequest(r *http.Request) (domains.ID, error)

LoadDocxFromRequest loads a document from an http.Request.

func (*Service) LoadMapFromFS

func (s *Service) LoadMapFromFS(actor *domains.Actor, clan *domains.Clan, path, name string, canDelete, canRead, canShare, canWrite bool) (domains.ID, error)

func (*Service) LoadMapFromRequest

func (s *Service) LoadMapFromRequest(r *http.Request) (domains.ID, error)

func (*Service) LoadReportFromFS

func (s *Service) LoadReportFromFS(actor *domains.Actor, clan *domains.Clan, path, name string, canDelete, canRead, canShare, canWrite bool) (domains.ID, error)

LoadReportFromFS loads the file, creates a Document, and returns the document ID.

func (*Service) LoadReportFromRequest

func (s *Service) LoadReportFromRequest(r *http.Request) (domains.ID, error)

LoadReportFromRequest loads a document from an http.Request.

func (*Service) ShareDocumentById

func (s *Service) ShareDocumentById(actor, ally *domains.Actor, documentId domains.ID, canRead, canDelete bool) error

ShareDocumentById shares a document.

Actor is the user requesting the share. The actor must own the document and have permission to read and share it.

Ally is the user that will own the shared document.

func (*Service) UpdateDocx

func (s *Service) UpdateDocx(doc *domains.Document) error

type UserDocumentView

type UserDocumentView struct {
	ID               string    `jsonapi:"primary,user-document"` // singular when sending a payload
	Owner            string    `jsonapi:"attr,owner"`            // handle of user that owns this document
	Game             string    `jsonapi:"attr,game"`
	Clan             string    `jsonapi:"attr,clan"`          // four-digit clan number
	DocumentName     string    `jsonapi:"attr,document-name"` // untainted name of document
	DocumentType     string    `jsonapi:"attr,document-type"` // for categorizing on the dashboards
	ProcessingStatus string    `jsonapi:"attr,processing-status,omitempty"`
	UpdatedAt        time.Time `jsonapi:"attr,updated-at,iso8601"`
}

UserDocumentView is the JSON:API for a user document. This view of the document includes the game information.

func (d *UserDocumentView) JSONAPILinks() *jsonapi.Links

JSONAPILinks implements the jsonapi.Linkable interface for user-document-links

Jump to

Keyboard shortcuts

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