From d7113b5237e0fc814452a9950d7110f5fd6783cf Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 5 Jul 2024 20:56:25 +0800 Subject: [PATCH] :bug: Fix back compability of draft state --- pkg/internal/services/articles.go | 2 +- pkg/internal/services/encryptor.go | 12 ------------ pkg/internal/services/posts.go | 2 +- 3 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 pkg/internal/services/encryptor.go diff --git a/pkg/internal/services/articles.go b/pkg/internal/services/articles.go index a29daf5..cdcc9e0 100644 --- a/pkg/internal/services/articles.go +++ b/pkg/internal/services/articles.go @@ -43,7 +43,7 @@ func FilterArticleWithAuthorDraft(tx *gorm.DB, uid uint) *gorm.DB { } func FilterArticleDraft(tx *gorm.DB) *gorm.DB { - return tx.Where("is_draft = ?", false) + return tx.Where("is_draft = ? OR is_draft IS NULL", false) } func GetArticleWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (models.Article, error) { diff --git a/pkg/internal/services/encryptor.go b/pkg/internal/services/encryptor.go deleted file mode 100644 index 8700731..0000000 --- a/pkg/internal/services/encryptor.go +++ /dev/null @@ -1,12 +0,0 @@ -package services - -import "golang.org/x/crypto/bcrypt" - -func HashPassword(raw string) string { - data, _ := bcrypt.GenerateFromPassword([]byte(raw), 12) - return string(data) -} - -func VerifyPassword(text string, password string) bool { - return bcrypt.CompareHashAndPassword([]byte(password), []byte(text)) == nil -} diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index a776e2e..c2c1fe5 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -51,7 +51,7 @@ func FilterPostWithAuthorDraft(tx *gorm.DB, uid uint) *gorm.DB { } func FilterPostDraft(tx *gorm.DB) *gorm.DB { - return tx.Where("is_draft = ?", false) + return tx.Where("is_draft = ? OR is_draft IS NULL", false) } func GetPostWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (models.Post, error) {