init
This commit is contained in:
30
bbs-go-active/server/internal/spam/captcha_strategy.go
Normal file
30
bbs-go-active/server/internal/spam/captcha_strategy.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package spam
|
||||
|
||||
import (
|
||||
"bbs-go/internal/models"
|
||||
"bbs-go/internal/pkg/errs"
|
||||
"bbs-go/internal/services"
|
||||
|
||||
"github.com/dchest/captcha"
|
||||
)
|
||||
|
||||
type CaptchaStrategy struct{}
|
||||
|
||||
func (CaptchaStrategy) Name() string {
|
||||
return "CaptchaStrategy"
|
||||
}
|
||||
|
||||
func (CaptchaStrategy) CheckTopic(user *models.User, form models.CreateTopicForm) error {
|
||||
if services.SysConfigService.GetConfig().TopicCaptcha && !captcha.VerifyString(form.CaptchaId, form.CaptchaCode) {
|
||||
return errs.CaptchaError
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (CaptchaStrategy) CheckArticle(user *models.User, form models.CreateArticleForm) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (CaptchaStrategy) CheckComment(user *models.User, form models.CreateCommentForm) error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user