feat!: (WIP) decouple storage, users, and configuration files to support multiple users

This commit is contained in:
krau
2025-02-18 17:17:02 +08:00
parent 9367419156
commit 968547b005
21 changed files with 474 additions and 372 deletions

View File

@@ -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;"`
}