mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-29 10:55:40 -04:00
api,frontend: add Akismet spam flagging integration
This commit is contained in:
31
api/akismet.go
Normal file
31
api/akismet.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/adtac/go-akismet/akismet"
|
||||
"os"
|
||||
)
|
||||
|
||||
func isSpam(domain string, userIp string, userAgent string, name string, email string, url string, markdown string) bool {
|
||||
akismetKey := os.Getenv("AKISMET_KEY")
|
||||
if akismetKey == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
res, err := akismet.Check(&akismet.Comment{
|
||||
Blog: domain,
|
||||
UserIP: userIp,
|
||||
UserAgent: userAgent,
|
||||
CommentType: "comment",
|
||||
CommentAuthor: name,
|
||||
CommentAuthorEmail: email,
|
||||
CommentAuthorURL: url,
|
||||
CommentContent: markdown,
|
||||
}, akismetKey)
|
||||
|
||||
if err != nil {
|
||||
logger.Errorf("error: cannot validate commenet using Akismet: %v", err)
|
||||
return true
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
Reference in New Issue
Block a user