owncloudsql

package
v2.19.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package owncloudsql implements a publiclink share manager backed by an existing ownCloud 10 database

The SQL queries use `coalesce({column_identifier}, ”) as {column_identifier}` to read an emptystring instead of null values, which better fits the golang default values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(driver string, db *sql.DB, c Config, userConverter UserConverter) (publicshare.Manager, error)

New returns a new Cache instance connecting to the given sql.DB

func NewMysql

func NewMysql(m map[string]interface{}) (publicshare.Manager, error)

NewMysql returns a new publicshare manager connection to a mysql database

Types

type Config

type Config struct {
	GatewayAddr                string `mapstructure:"gateway_addr"`
	DbUsername                 string `mapstructure:"db_username"`
	DbPassword                 string `mapstructure:"db_password"`
	DbHost                     string `mapstructure:"db_host"`
	DbPort                     int    `mapstructure:"db_port"`
	DbName                     string `mapstructure:"db_name"`
	EnableExpiredSharesCleanup bool   `mapstructure:"enable_expired_shares_cleanup"`
	SharePasswordHashCost      int    `mapstructure:"password_hash_cost"`
}

Config configures an owncloudsql publicshare manager

type DBShare

type DBShare struct {
	ID           string
	UIDOwner     string
	UIDInitiator string
	ItemStorage  string
	FileSource   string
	ItemType     string // 'file' or 'folder'
	ShareWith    string
	Token        string
	Expiration   string
	Permissions  int
	ShareType    int
	ShareName    string
	STime        int
	FileTarget   string
	RejectedBy   string
	State        int
	Parent       int
}

DBShare stores information about user and public shares.

type GatewayUserConverter

type GatewayUserConverter struct {
	IDCache   *ttlcache.Cache
	NameCache *ttlcache.Cache
	// contains filtered or unexported fields
}

GatewayUserConverter converts usernames and ids using the gateway

func NewGatewayUserConverter

func NewGatewayUserConverter(gwAddr string) *GatewayUserConverter

NewGatewayUserConverter returns a instance of GatewayUserConverter

func (*GatewayUserConverter) UserIDToUserName

func (c *GatewayUserConverter) UserIDToUserName(ctx context.Context, userid *userpb.UserId) (string, error)

UserIDToUserName converts a user ID to an username

func (*GatewayUserConverter) UserNameToUserID

func (c *GatewayUserConverter) UserNameToUserID(ctx context.Context, username string) (*userpb.UserId, error)

UserNameToUserID converts a username to an user ID

type UserConverter

type UserConverter interface {
	UserNameToUserID(ctx context.Context, username string) (*userpb.UserId, error)
	UserIDToUserName(ctx context.Context, userid *userpb.UserId) (string, error)
}

UserConverter describes an interface for converting user ids to names and back

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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