controller

package
v0.0.0-...-77120ca Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CanReadFile

type CanReadFile struct {
	UserUUID uuid.UUID `json:"userUUID"`
	FileUUID uuid.UUID `json:"fileUUID"`
}

type Controller

type Controller struct {
	DB *gorm.DB
}

func Default

func Default() (c *Controller, err error)

func New

func New(db *gorm.DB) (c *Controller, err error)

func (*Controller) CanReadFile

func (c *Controller) CanReadFile(crf *CanReadFile) (err error)

Can read file is inteded to be used internally by other operations of the metadata Will check if user owns the file Or iif user has at least access by share directly or indirectly

func (*Controller) Close

func (c *Controller) Close() (err error)

func (*Controller) CreateFile

func (c *Controller) CreateFile(cf *CreateFile) (file models.File, err error)

Creates a new file in the filesystem index

func (*Controller) DeleteFile

func (c *Controller) DeleteFile(df *DeleteFile) (err error)

Deletes file from the index

func (*Controller) MoveFile

func (c *Controller) MoveFile(mf *MoveFile) (err error)

func (*Controller) QueryFile

func (c *Controller) QueryFile(qf *QueryFile) (archive models.Archive, err error)

Intended to only be used by the Gateway The server checks if the user owns the file. If not the server tries to determine the access to the file by shared files with this account

func (*Controller) ShareFile

func (c *Controller) ShareFile(sr *ShareRequest) (err error)

Use to share a file other users in the system Intended to be called after obtaining the UUID of the account thanks to the authentication service

func (*Controller) ShareWithMe

func (c *Controller) ShareWithMe(swm *ShareWithMe) (shared []models.SharedFile, err error)

Used to list all the files shared with the current user

func (*Controller) ShareWithWho

func (c *Controller) ShareWithWho(sww *ShareWithWho) (shared []models.SharedFile, err error)

Used to query users that have access to a file

func (*Controller) UnshareFile

func (c *Controller) UnshareFile(sr *ShareRequest) (err error)

Work almost the same as the ShareFile but intended to remove files

type CreateFile

type CreateFile struct {
	Filename        string     `json:"filename"`
	OwnerUUID       uuid.UUID  `json:"ownerUUID"`
	Hash            string     `json:"hash,omitempty"`
	ParentDirectory *uuid.UUID `json:"parentDirectory,omitempty"`
	Size            uint64     `json:"size,omitempty"`
}

type DeleteFile

type DeleteFile struct {
	OwnerUUID uuid.UUID `json:"ownerUUID"`
	FileUUID  uuid.UUID `json:"fileUUID"`
}

type MoveFile

type MoveFile struct {
	OwnerUUID   uuid.UUID  `json:"ownerUUID"`
	FileUUID    uuid.UUID  `json:"fileUUID"`
	NewLocation *uuid.UUID `json:"newLocation,omitempty"`
	NewName     *string    `json:"newName,omitempty"`
}

type QueryFile

type QueryFile struct {
	UserUUID uuid.UUID `json:"userUUID"`
	FileUUID uuid.UUID `json:"fileUUID"`
}

type ShareRequest

type ShareRequest struct {
	OwnerUUID      uuid.UUID `json:"ownerUUID"`
	FileUUID       uuid.UUID `json:"fileUUID"`
	TargetUserUUID uuid.UUID `json:"targetUserUUID"`
}

type ShareWithMe

type ShareWithMe struct {
	UserUUID uuid.UUID `json:"userUUID"`
}

type ShareWithWho

type ShareWithWho struct {
	OwnerUUID uuid.UUID `json:"ownerUUID"`
	FileUUID  uuid.UUID `json:"fileUUID"`
}

Jump to

Keyboard shortcuts

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