mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 13:29:56 +02:00
* chore: intake email attachment * chore: add rate limit for intake form issues * chore: add attachments for intake issues * chore: add logging in email service * chore: remove patch endpoint url * chore: remove private key * chore: update formatting * chore: move intake anchor function to separate utility file * chore: added anchor based rate limiting * chore: update rate limit
66 lines
1.4 KiB
Go
66 lines
1.4 KiB
Go
package parser
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func IsSpam(content string) bool {
|
|
spamWords, err := os.ReadFile("spam.txt")
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return false
|
|
}
|
|
// convert spamWords to string
|
|
spamWordsStr := string(spamWords)
|
|
spamWordsArr := strings.Split(spamWordsStr, "\n")
|
|
|
|
for _, word := range spamWordsArr {
|
|
word = strings.TrimSpace(word)
|
|
if word != "" && strings.Contains(strings.ToLower(content), word) {
|
|
fmt.Println("Detected spam word: ", word)
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func IsBacklistedDomain(email string) bool {
|
|
blacklistedDomains, err := os.ReadFile("domain-blacklist.txt")
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return false
|
|
}
|
|
// convert blacklistedDomains to string
|
|
blacklistedDomainsStr := string(blacklistedDomains)
|
|
// blacklistedDomainsArr := strings.Split(blacklistedDomainsStr, "\n")
|
|
|
|
atIndex := strings.LastIndex(email, "@")
|
|
if atIndex == -1 {
|
|
return true
|
|
}
|
|
emailDomain := email[atIndex+1:]
|
|
return strings.Contains(blacklistedDomainsStr, emailDomain+"\n")
|
|
}
|
|
|
|
func ValidateWorkspaceAnchor(email string) (string, string) {
|
|
// Split the email at "@"
|
|
workspaceAnchor := strings.Split(email, "@")
|
|
if len(workspaceAnchor) == 0 {
|
|
return "", ""
|
|
}
|
|
|
|
// Split the anchor part at the last "-"
|
|
anchorParts := strings.SplitN(workspaceAnchor[0], "-", 2)
|
|
if len(anchorParts) != 2 {
|
|
return "", ""
|
|
}
|
|
|
|
workspaceSlug := anchorParts[0]
|
|
publishAnchor := anchorParts[1]
|
|
|
|
return publishAnchor, workspaceSlug
|
|
}
|