feat!: (WIP) switched back to using config files config storages because the conversation handling is shit

This commit is contained in:
krau
2025-02-19 11:05:30 +08:00
parent 80696c9661
commit 692e970772
24 changed files with 584 additions and 645 deletions

View File

@@ -1,10 +1,6 @@
package types
import (
"crypto/md5"
"encoding/hex"
"gorm.io/datatypes"
"gorm.io/gorm"
)
@@ -22,33 +18,7 @@ type ReceivedFile struct {
type User struct {
gorm.Model
ChatID int64 `gorm:"uniqueIndex;not null"`
Silent bool
DefaultStorageID uint
Storages []*StorageModel `gorm:"many2many:user_storages;"`
}
type StorageModel struct {
gorm.Model
Type string
Config datatypes.JSON
Active bool
Users []*User `gorm:"many2many:user_storages;"`
Hash string `gorm:"uniqueIndex"`
// just for display
Name string `gorm:"not null"`
Desc string
}
func (s *StorageModel) GenHash() string {
if s.Type == "" || s.Config == nil {
return ""
}
typeBytes := []byte(s.Type)
configBytes := s.Config
structBytes := append(typeBytes, configBytes...)
hash := md5.New()
hash.Write(structBytes)
hashBytes := hash.Sum(nil)
return hex.EncodeToString(hashBytes)
ChatID int64 `gorm:"uniqueIndex;not null"`
Silent bool
DefaultStorage string // Default storage name
}

View File

@@ -39,7 +39,7 @@ type Task struct {
Error error
Status TaskStatus
File *File
StorageID uint
StorageName string
StoragePath string
StartTime time.Time