database

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDirForUser

func CreateDirForUser(ctx context.Context, userID uint, storageName, path string) error

func CreateRule

func CreateRule(ctx context.Context, rule *Rule) error

func CreateUser

func CreateUser(ctx context.Context, chatID int64) error

func DeleteDirByID

func DeleteDirByID(ctx context.Context, id uint) error

func DeleteDirForUser

func DeleteDirForUser(ctx context.Context, userID uint, storageName, path string) error

func DeleteRule

func DeleteRule(ctx context.Context, ruleID uint) error

func DeleteUser

func DeleteUser(ctx context.Context, user *User) error

func Init

func Init(ctx context.Context)

func UpdateUser

func UpdateUser(ctx context.Context, user *User) error

func UpdateUserApplyRule

func UpdateUserApplyRule(ctx context.Context, chatID int64, applyRule bool) error

Types

type Dir

type Dir struct {
	gorm.Model
	UserID      uint
	StorageName string
	Path        string
}

func GetDirByID

func GetDirByID(ctx context.Context, id uint) (*Dir, error)

func GetDirsByUserChatIDAndStorageName

func GetDirsByUserChatIDAndStorageName(ctx context.Context, chatID int64, storageName string) ([]Dir, error)

func GetDirsByUserIDAndStorageName

func GetDirsByUserIDAndStorageName(ctx context.Context, userID uint, storageName string) ([]Dir, error)

func GetUserDirs

func GetUserDirs(ctx context.Context, userID uint) ([]Dir, error)

func GetUserDirsByChatID

func GetUserDirsByChatID(ctx context.Context, chatID int64) ([]Dir, error)

type Rule

type Rule struct {
	gorm.Model
	UserID      uint
	Type        string
	Data        string
	StorageName string
	DirPath     string
}

func GetRulesByUserChatID

func GetRulesByUserChatID(ctx context.Context, chatID int64) ([]Rule, error)

type User

type User struct {
	gorm.Model
	ChatID           int64 `gorm:"uniqueIndex;not null"`
	Silent           bool
	DefaultStorage   string
	DefaultDir       uint // Dir.ID
	Dirs             []Dir
	ApplyRule        bool
	Rules            []Rule
	WatchChats       []WatchChat
	FilenameStrategy string
	FilenameTemplate string
}

func GetAllUsers

func GetAllUsers(ctx context.Context) ([]User, error)

func GetUserByChatID

func GetUserByChatID(ctx context.Context, chatID int64) (*User, error)

func GetUserByID added in v0.28.0

func GetUserByID(ctx context.Context, id uint) (*User, error)

func (*User) UnwatchChat added in v0.28.0

func (user *User) UnwatchChat(ctx context.Context, chatID int64) error

func (*User) WatchChat added in v0.28.0

func (user *User) WatchChat(ctx context.Context, chat WatchChat) error

func (*User) WatchingChat added in v0.28.0

func (user *User) WatchingChat(ctx context.Context, chatID int64) (bool, error)

type WatchChat added in v0.28.0

type WatchChat struct {
	gorm.Model
	UserID uint // User's database ID (not chat ID)
	ChatID int64
	Filter string
}

func GetWatchChatsByChatID added in v0.28.0

func GetWatchChatsByChatID(ctx context.Context, chatID int64) ([]*WatchChat, error)

Jump to

Keyboard shortcuts

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