feat!: (WIP) decouple storage, users, and configuration files to support multiple users
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"gorm.io/datatypes"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ReceivedFile struct {
|
||||
gorm.Model
|
||||
Processing bool
|
||||
ChatID int64 `gorm:"uniqueIndex:idx_chat_id_message_id;not null"`
|
||||
MessageID int `gorm:"uniqueIndex:idx_chat_id_message_id;not null"`
|
||||
Processing bool
|
||||
// Which chat the file is from
|
||||
ChatID int64 `gorm:"uniqueIndex:idx_chat_id_message_id;not null"`
|
||||
// Which message the file is from
|
||||
MessageID int `gorm:"uniqueIndex:idx_chat_id_message_id;not null"`
|
||||
ReplyMessageID int
|
||||
ReplyChatID int64
|
||||
FileName string
|
||||
@@ -16,7 +19,18 @@ type ReceivedFile struct {
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
UserID int64 `gorm:"uniqueIndex"`
|
||||
Silent bool
|
||||
DefaultStorage string
|
||||
ChatID int64 `gorm:"uniqueIndex"` // Telegram user ID
|
||||
Silent bool
|
||||
DefaultStorageID uint
|
||||
Storages []*StorageModel `gorm:"many2many:user_storages;"`
|
||||
}
|
||||
|
||||
type StorageModel struct {
|
||||
gorm.Model
|
||||
Type string
|
||||
Name string // just for display
|
||||
Desc string
|
||||
Active bool
|
||||
Config datatypes.JSON
|
||||
Users []*User `gorm:"many2many:user_storages;"`
|
||||
}
|
||||
|
||||
@@ -22,20 +22,20 @@ var (
|
||||
type StorageType string
|
||||
|
||||
var (
|
||||
StorageAll StorageType = "all"
|
||||
Local StorageType = "local"
|
||||
Webdav StorageType = "webdav"
|
||||
Alist StorageType = "alist"
|
||||
StorageAll StorageType = "all"
|
||||
StorageTypeLocal StorageType = "local"
|
||||
StorageTypeWebdav StorageType = "webdav"
|
||||
StorageTypeAlist StorageType = "alist"
|
||||
)
|
||||
|
||||
var StorageTypes = []StorageType{Local, Alist, Webdav, StorageAll}
|
||||
var StorageTypes = []StorageType{StorageTypeLocal, StorageTypeAlist, StorageTypeWebdav, StorageAll}
|
||||
|
||||
type Task struct {
|
||||
Ctx context.Context
|
||||
Error error
|
||||
Status TaskStatus
|
||||
File *File
|
||||
Storage StorageType
|
||||
StorageID uint
|
||||
StoragePath string
|
||||
StartTime time.Time
|
||||
|
||||
|
||||
Reference in New Issue
Block a user