public void Report(Comment comment) { if (_api == null) { Initialize(); } if (_settings == null) { InitSettings(); } AkismetComment akismetComment = GetAkismetComment(comment); if (comment.IsApproved) { Utils.Log(string.Format("Akismet: Reporting NOT spam from \"{0}\" at \"{1}\"", comment.Author, comment.IP)); _api.SubmitHam(akismetComment); } else { Utils.Log(string.Format("Akismet: Reporting SPAM from \"{0}\" at \"{1}\"", comment.Author, comment.IP)); _api.SubmitSpam(akismetComment); } }
public static void MarkSpam(PostComments.Comment comment) { var api = new Akismet(AkismetKey, BlogUrl, comment.UserAgent); if (!api.VerifyKey()) { throw new Exception("Akismet API key invalid."); } var akismetComment = new AkismetComment { Blog = BlogUrl, UserIp = comment.UserHostAddress, UserAgent = comment.UserAgent, CommentContent = comment.Body, CommentType = "comment", CommentAuthor = comment.Author, CommentAuthorEmail = comment.Email, CommentAuthorUrl = comment.Url, }; #if !DEBUG api.SubmitSpam(akismetComment); #endif }
public void MarkSpam(PostComments.Comment comment) { //Create a new instance of the Akismet API and verify your key is valid. string blog = ConfigurationManager.AppSettings["MainUrl"]; var api = new Akismet(akismetKey, blog, comment.UserAgent); if (!api.VerifyKey()) { throw new Exception("Akismet API key invalid."); } var akismetComment = new AkismetComment { Blog = blog, UserIp = comment.UserHostAddress, UserAgent = comment.UserAgent, CommentContent = comment.Body, CommentType = "comment", CommentAuthor = comment.Author, CommentAuthorEmail = comment.Email, CommentAuthorUrl = comment.Url, }; #if !DEBUG api.SubmitSpam(akismetComment); #endif }
/// <summary> /// This call is for submitting comments that weren't marked as spam but should've been. /// </summary> /// <param name="comment">The comment.</param> public void SubmitSpam(CheckCommentForSpam comment) { if (VerifyKey) { AkismetComment akismetComment = ConvertCommentToAkismetComment(comment); Service.SubmitSpam(akismetComment); } }
private void ValidateUpdatingComment(Comment comment) { var catchSpamInComments = Config.Get <AkismetModuleConfig>().ProtectComments; if (catchSpamInComments) { var blogsMan = BlogsManager.GetManager(string.Empty, "DummyTransaction"); var existingComment = SystemManager.GetCommentsService().GetComment(comment.Id.ToString()); if (existingComment != null && existingComment.Status != comment.Status.ToString()) { Akismet akismetApiClient = new Akismet(Config.Get <AkismetModuleConfig>().ApiKey, "http://www.sitefinity.com", "SitefinityAkismetModule"); if (!akismetApiClient.VerifyKey()) { return; } var akismetDbContext = new AkismetEntityContext(); var existingAkismetData = akismetDbContext.AkismetDataList.SingleOrDefault(a => a.ContentItemId == comment.Id); if (existingAkismetData != null) { var updatedComment = new AkismetComment() { Blog = "http://www.sitefinity.com", CommentContent = comment.Content, CommentType = "comment", Referrer = existingAkismetData.Referrer, UserAgent = existingAkismetData.UserAgent, UserIp = existingAkismetData.UserIP, CommentAuthor = comment.AuthorName, CommentAuthorEmail = comment.Email, CommentAuthorUrl = comment.Website }; if (comment.CommentStatus.ToString() == Telerik.Sitefinity.Services.Comments.StatusConstants.Spam) { // the item has been marked as spam akismetApiClient.SubmitSpam(updatedComment); } else { // the item has been marked as ham akismetApiClient.SubmitHam(updatedComment); } } } } }
private void ValidateUpdatingForumPost(ForumPost post, string origin, Guid userId) { var catchSpamInForums = Config.Get <AkismetModuleConfig>().ProtectForums; if (catchSpamInForums) { var forumsMan = ForumsManager.GetManager(string.Empty, "DummyTransaction"); var existingPost = forumsMan.GetPost(post.Id); if (existingPost != null && existingPost.IsMarkedSpam != post.IsMarkedSpam) { Akismet akismetApiClient = new Akismet(Config.Get <AkismetModuleConfig>().ApiKey, "http://www.sitefinity.com", "SitefinityAkismetModule"); if (!akismetApiClient.VerifyKey()) { return; } var akismetDbContext = new AkismetEntityContext(); var existingAkismetData = akismetDbContext.AkismetDataList.SingleOrDefault(a => a.ContentItemId == post.Id); if (existingAkismetData != null) { var updatedForumPost = new AkismetComment() { Blog = "http://www.sitefinity.com", CommentContent = post.Content, CommentType = "comment", Referrer = existingAkismetData.Referrer, UserAgent = existingAkismetData.UserAgent, UserIp = existingAkismetData.UserIP, }; if (post.IsMarkedSpam) { // the item has been marked as spam akismetApiClient.SubmitSpam(updatedForumPost); } else { // the item has been marked as ham akismetApiClient.SubmitHam(updatedForumPost); } } } } }
/// <summary> /// Report mistakes back to service /// </summary> /// <param name="comment">BlogEngine comment</param> public void Report(Comment comment) { if (api == null) { this.Initialize(); } var akismetComment = GetAkismetComment(comment); if (comment.IsApproved) { Utils.Log(string.Format("TypePad: Reporting NOT spam from \"{0}\" at \"{1}\"", comment.Author, comment.IP)); api.SubmitHam(akismetComment); } else { Utils.Log(string.Format("TypePad: Reporting SPAM from \"{0}\" at \"{1}\"", comment.Author, comment.IP)); api.SubmitSpam(akismetComment); } }
public JsonResult ChangeSpamMark(int id) { Comment comment = CommentServices.FindEntityByIdentity(id); //Create a new instance of the Akismet API and verify your key is valid. Akismet api = new Akismet(BgResources.Akismet_API_key, Request.Url.AbsoluteUri, HttpContext.Request.UserAgent); if (!api.VerifyKey()) { return(Json(new { result = "error", text = Resources.AppMessages.AkismetApikeyInvalid })); } //Now create an instance of AkismetComment, populating it with values //from the POSTed form collection. AkismetComment akismetComment = new AkismetComment { Blog = Request.Url.Scheme + "://" + Request.Url.Host, UserIp = comment.Ip, UserAgent = comment.UserAgent, CommentContent = comment.Message, CommentType = "comment", CommentAuthor = comment.AnonymousUser != null ? comment.AnonymousUser.Username : comment.User.Username, CommentAuthorEmail = comment.AnonymousUser != null ? comment.AnonymousUser.Email : comment.User.Email, CommentAuthorUrl = comment.AnonymousUser != null ? comment.AnonymousUser.Web : String.Empty }; if (comment.IsSpam) { comment.IsSpam = false; api.SubmitHam(akismetComment); } else { comment.IsSpam = true; api.SubmitSpam(akismetComment); } BlogServices.SaveComment(comment); return(Json(new { result = "ok" })); }