office

package
v0.0.0-...-7abac79 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: AGPL-3.0 Imports: 22 Imported by: 1

Documentation

Overview

Package office is for interactions with an OnlyOffice server to allow users to view/edit their office documents online.

Index

Constants

View Source
const (
	// StatusReadyForSaving is used when the file should be saved after being
	// edited.
	StatusReadyForSaving = 2
	// StatusForceSaveRequested is used when the file has been modified and
	// should be saved, even if the document is still opened and can be edited
	// by users.
	StatusForceSaveRequested = 6
)

Status list is described on https://api.onlyoffice.com/editors/callback#status

View Source
const OOSlug = "onlyoffice-server"

OOSlug is the slug for uploadedBy field of the CozyMetadata when a file has been modified in the online OnlyOffice.

Variables

View Source
var (
	// ErrNoServer is used when no OnlyOnffice server is configured for the
	// current context
	ErrNoServer = errors.New("No OnlyOnffice server is configured")
	// ErrInvalidFile is used when a file is not an office document
	ErrInvalidFile = errors.New("Invalid file, not an office document")
	// ErrInternalServerError is used when something goes wrong (like no
	// connection to redis)
	ErrInternalServerError = errors.New("Internal server error")
	// ErrInvalidKey is used when the key is not found in the store
	ErrInvalidKey = errors.New("invalid key")
)

Functions

func Callback

func Callback(inst *instance.Instance, params CallbackParameters) error

Callback will manage the callback from the document server.

func EnsureFileForKey

func EnsureFileForKey(inst *instance.Instance, key string) (*vfs.FileDoc, error)

EnsureFileForKey returns the file that will be written when OnlyOffice will save a document with the given key. The general case is that is the file that has been opened. But, it can also be a new file if a conflict has happened because a new version has been uploaded for this file (by the desktop client for example).

func GetConfig

func GetConfig(contextName string) *config.Office

Types

type CallbackParameters

type CallbackParameters struct {
	Key    string `json:"key"`
	Status int    `json:"status"`
	URL    string `json:"url"`
	Token  string `json:"-"` // From the Authorization header
}

CallbackParameters is a struct for the parameters sent by the document server to the stack. Cf https://api.onlyoffice.com/editors/callback

type ConflictDetector

type ConflictDetector struct {
	ID     string
	Rev    string
	MD5Sum []byte
}

type Store

type Store interface {
	GetSecretByID(db prefixer.Prefixer, id string) (string, error)
	UpdateSecret(db prefixer.Prefixer, secret, oldID, newID string) error
	AddDoc(db prefixer.Prefixer, payload ConflictDetector) (string, error)
	GetDoc(db prefixer.Prefixer, secret string) (*ConflictDetector, error)
	UpdateDoc(db prefixer.Prefixer, secret string, payload ConflictDetector) error
	RemoveDoc(db prefixer.Prefixer, secret string) error
}

Store is an object to store and retrieve document server keys <-> id,rev

func GetStore

func GetStore() Store

GetStore returns the store for temporary move objects.

Jump to

Keyboard shortcuts

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