feat!: (WIP) switched back to using config files config storages because the conversation handling is shit
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ type Task struct {
|
||||
Error error
|
||||
Status TaskStatus
|
||||
File *File
|
||||
StorageID uint
|
||||
StorageName string
|
||||
StoragePath string
|
||||
StartTime time.Time
|
||||
|
||||
|
||||
Reference in New Issue
Block a user