Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinmoris committed Jul 17, 2022
2 parents 387d69a + 7c05bd1 commit becdb24
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/DustedCodes/Messages.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ module Messages =
open System.Threading
open System.Threading.Tasks

let private containsSpam (str : string) =
[
"XEVIL 5"
"captchas solving"
"captcha solving"
]
|> List.map (fun s -> s.ToLower())
|> List.exists (str.ToLower().Contains)

[<CLIMutable>]
type Request =
{
Expand Down Expand Up @@ -39,11 +48,16 @@ module Messages =
Message = ""
}

member this.IsSpam =
containsSpam this.Subject
|| containsSpam this.Message

member this.IsValid =
if String.IsNullOrEmpty this.Name then Error "Name cannot be empty."
else if String.IsNullOrEmpty this.Email then Error "Email address cannot be empty."
else if String.IsNullOrEmpty this.Subject then Error "Subject cannot be empty."
else if String.IsNullOrEmpty this.Message then Error "Message cannot be empty."
else if this.IsSpam then Error "Cannot process this message"
else Ok ()

member this.ToRequest
Expand Down Expand Up @@ -89,4 +103,4 @@ module Messages =
| Error err ->
log Level.Error (sprintf "Failed to send message to MailDrop: %s" err)
Error "Message could not be saved. Please try again later."
}
}

0 comments on commit becdb24

Please sign in to comment.