internal

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTH_COOKIE    = "auth"
	LINKING_COOKIE = "linking"
)
View Source
const Version = "v0.4.0"

Variables

View Source
var ErrCantDeleteSelf = fmt.Errorf("you can't delete yourself")
View Source
var ErrInvalidAuthCookie = errors.New("invalid session token")
View Source
var ErrInvalidDatabaseType = errors.New("invalid database type")
View Source
var ErrUnknownStorageMethod = errors.New("unknown file storage method")

Functions

func MigrateExistingDatabase

func MigrateExistingDatabase(
	ctx context.Context,
	database *gorm.DB,
	databaseType string,
	databaseConnectionUrl string,
	migrator migrate.RevisionReadWriter,
	sqlDB *sql.DB,
	dir *migrate.MemDir,
) (err error)

Temporary code to migrate from existing database from before migration system Can be dumped in the future

func ProviderToIcon

func ProviderToIcon(provider string) string

func ProviderToLinkingText

func ProviderToLinkingText(provider string) string

func RunMigrations

func RunMigrations(database *gorm.DB, databaseType string, databaseConnectionUrl string) (err error)

func Sum

func Sum[T any](slice []T, getValue func(T) int) int

Types

type AccountStats

type AccountStats struct {
	db.Accounts

	SpaceUsed         uint
	InvitedBy         string
	FilesUploaded     int64
	You               bool
	SessionsCount     int64
	UploadTokensCount int64
	LastActivity      time.Time // Last session or upload token usage
}

type Application

type Application struct {
	RateLimiter *limiter.Limiter
	Router      *gin.Engine
	// contains filtered or unexported fields
}

func InitializeApplication

func InitializeApplication() *Application

func (*Application) CleanUpJob

func (app *Application) CleanUpJob()

func (*Application) Run

func (app *Application) Run()

func (*Application) Shutdown

func (app *Application) Shutdown()

func (*Application) StartJobScheduler

func (app *Application) StartJobScheduler()

type Config

type Config struct {
	DataFolder            string `toml:"data_folder"`
	MaxUploadSize         int64  `toml:"max_upload_size"`
	DatabaseType          string `toml:"database_type"`
	DatabaseConnectionUrl string `toml:"database_connection_url"`

	Port       int    `toml:"port"`
	UnixSocket string `toml:"unix_socket"`

	BehindReverseProxy bool   `toml:"behind_reverse_proxy"`
	TrustedProxy       string `toml:"trusted_proxy"`
	PublicUrl          string `toml:"public_url"` // URL to use for github callback and cookies, e.g http://cdn.example.com
	CookieDomain       string // hostname extracted from PublicUrl
	CookieSecure       bool   // true when PublicUrl is https

	Branding string `toml:"branding"` // Branding text for toolbar (max 20 characters)
	Tagline  string `toml:"tagline"`  // Used for meta description and text on index page (max 100 characters)

	FileStorageMethod fileStorageMethod
	S3                s3Config `toml:"s3"`
}

type FileStatsOutput

type FileStatsOutput struct {
	Count     uint     `json:"count"`
	SizeTotal uint     `json:"size_total"`
	Tags      []string `json:"tags"`
}

type FilesApiInput

type FilesApiInput struct {
	Skip   uint   `form:"skip,default=0"`          // Used for pagination
	Sort   string `form:"sort,default=created_at"` // "created_at", "views", "file_size"
	Desc   bool   `form:"desc,default=true"`       // true for descending, false for ascending
	Tag    string `form:"tag"`                     // optional tag filter
	Filter string `form:"filter"`                  // "untagged" for files without tags, "public" for public files, "private" for private files
}

type FilesApiOutput

type FilesApiOutput struct {
	Files []db.Files `json:"files"`
	Count int64      `json:"count"`
}

type LoginProvider

type LoginProvider struct {
	Name string
	Icon string // lucide-icon name, should probably be replaced with simpleicons.org when supporting more login platforms
}

type ProviderInfo

type ProviderInfo struct {
	Name        string
	Icon        string // lucide-icon name, should probably be replaced with simpleicons.org when supporting more login platforms
	LinkingText string // e.g., "Link with GitHub"
	IsLinked    bool   // whether the account is linked to this provider
	Username    string // Used for displaying linked username
	ProfileURL  string // Profile URL if the provider supports it, e.g for github you can open your profile
}

type SessionTokenVerification

type SessionTokenVerification struct {
	SessionToken string `form:"token"`
}

type TagInput

type TagInput struct {
	FileName string `form:"file_name" binding:"required"`
	Tag      string `form:"tag"       binding:"required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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