public static AkismetStatus SubmitHam(this AkismetStatus commentStatus, IAkismetService akismet) { if (commentStatus.IsHam) { akismet.SubmitHam(commentStatus.Comment); } return(commentStatus); }
public AkismetStatus Process(AkismetComment comment, ISettings blogSettings) { var commentStatus = new AkismetStatus(comment); commentStatus.CheckIfSpamOrHam(_akismetService) .SubmitSpam(_akismetService) .SubmitHam(_akismetService); return(commentStatus); }
public AkismetStatus ProcessComment() { var akismetEnabled = _settingsRepository.BlogAkismetEnabled; var deleteSpam = _settingsRepository.BlogAkismetDeleteSpam; var akismetStatus = new AkismetStatus(); if (akismetEnabled && !_requestData.IsAuthenticated) { /* If the url or akismet key is invalid, this part * might throw an exception. If it does, the comment * is swallowed, as we do not know the status of the * comment. If it happens, just correct the url or the * key and you should be fine! * * */ var comment = AkismetComment.Create(_commentEntity, _requestData); var akistmetPipeline = new AkismetPipeline(_akismetService); try { akismetStatus = akistmetPipeline.Process(comment, _settingsRepository); if (akismetStatus.IsSpam && !deleteSpam) { _commentEntity.CommentStatus = 2; // its spam _commentRepository.AddComment(_commentEntity); } else if (akismetStatus.IsHam) { _commentEntity.CommentStatus = 0; _commentRepository.AddComment(_commentEntity); } } catch (Exception exception) { _error.InsertException(exception); } } else { // submit the comment, mark as approved if the user is logged in _commentEntity.CommentStatus = _requestData.IsAuthenticated ? 0 : 1; _commentRepository.AddComment(_commentEntity); } return(akismetStatus); }
public static AkismetStatus CheckIfSpamOrHam(this AkismetStatus commentStatus, IAkismetService akismet) { commentStatus.IsSpam = akismet.CommentCheck(commentStatus.Comment); commentStatus.IsHam = !commentStatus.IsSpam; return(commentStatus); }