refactor, sketch SSE implementation

This commit is contained in:
Carl Pearson
2024-10-19 06:02:54 -06:00
parent 459e899efe
commit 22a82d0e4c
11 changed files with 266 additions and 124 deletions

View File

@@ -8,16 +8,8 @@ import (
"ytdlp-site/originals"
"github.com/google/uuid"
"golang.org/x/crypto/bcrypt"
"gorm.io/gorm"
)
type User struct {
gorm.Model
Username string `gorm:"unique"`
Password string
}
type TempURL struct {
Token string `gorm:"uniqueIndex"`
FilePath string
@@ -37,15 +29,6 @@ type DownloadManager struct {
mutex sync.RWMutex
}
func CreateUser(db *gorm.DB, username, password string) error {
hashedPassword, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
user := User{Username: username, Password: string(hashedPassword)}
if err := db.Create(&user).Error; err != nil {
return err
}
return nil
}
func SetOriginalStatus(id uint, status originals.Status) error {
return db.Model(&originals.Original{}).Where("id = ?", id).Update("status", status).Error
}