model

package
v3.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	// Id has to be called Id and not ID, otherwise the foreign key will not work
	// ID is a special field in GORM, which it uses as the default Primary Key
	Id        uint    `gorm:"primaryKey;not null;autoIncrement:false"`
	ShareId   ShareID `gorm:"foreignKey:Id;references:ID;constraint:OnDelete:CASCADE"` //;references:ID
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

We cannot use gorm.Model, because we want our ID to be a foreign key to ShareID

type ItemType

type ItemType string
const (
	ItemTypeFile      ItemType = "file"
	ItemTypeFolder    ItemType = "folder"
	ItemTypeReference ItemType = "reference"
	ItemTypeSymlink   ItemType = "symlink"
)

func (ItemType) String

func (i ItemType) String() string

type ProtoShare

type ProtoShare struct {
	// Including gorm.Model will embed a number of gorm-default fields
	BaseModel
	UIDOwner     string   `gorm:"size:64"`
	UIDInitiator string   `gorm:"size:64;index"`
	ItemType     ItemType `gorm:"size:16;index"` // file | folder | reference | symlink
	InitialPath  string
	Inode        string `gorm:"size:32;index"`
	Instance     string `gorm:"size:32;index"`
	Permissions  uint8
	Orphan       bool
	Expiration   datatypes.NullTime
}

ProtoShare contains fields that are shared between PublicLinks and Shares. Unfortunately, because these are shared, we cannot name our indexes because then two indexes with the same name would be created

type PublicLink struct {
	ProtoShare
	// Current tokens are only 16 chars long, but old tokens used to be 32 characters
	Token                        string `gorm:"uniqueIndex:i_token;size:32"`
	Quicklink                    bool
	NotifyUploads                bool
	NotifyUploadsExtraRecipients string
	Password                     string `gorm:"size:255"`
	// Users can give a name to a share
	LinkName string `gorm:"size:512"`
}

func (*PublicLink) AsCS3PublicShare

func (p *PublicLink) AsCS3PublicShare() *link.PublicShare

type Share

type Share struct {
	ProtoShare
	ShareWith         string `gorm:"size:255;index:i_share_with"` // 255 because this can be a lw account, which are mapped from email addresses / ...
	SharedWithIsGroup bool
	Description       string `gorm:"size:1024"`
}

func (*Share) AsCS3ReceivedShare

func (s *Share) AsCS3ReceivedShare(state *ShareState, granteeType userpb.UserType) *collaboration.ReceivedShare

func (*Share) AsCS3Share

func (s *Share) AsCS3Share(granteeType userpb.UserType) *collaboration.Share

type ShareID

type ShareID struct {
	ID uint `gorm:"primarykey"`
}

type ShareState

type ShareState struct {
	gorm.Model
	ShareID uint  `gorm:"uniqueIndex:i_shareid_user"`       // Define the foreign key field
	Share   Share `gorm:"foreignKey:ShareID;references:Id"` // Define the association
	// Can not be uid because of lw accs
	User   string `gorm:"uniqueIndex:i_shareid_user;size:255"`
	Synced bool
	Hidden bool
	Alias  string `gorm:"size:64"`
}

Jump to

Keyboard shortcuts

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