From 8d039903f630db0b89f2df44a94f4e5c938bd7bf Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 17 Oct 2023 11:43:07 -0400 Subject: Added marking comments as spam --- app/controllers/admin/comments_controller.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/controllers/admin/comments_controller.rb') diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 9958232..d3d948c 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -31,6 +31,29 @@ class Admin::CommentsController < Admin::AdminController redirect_to pending_admin_comments_url end + def mark_spam + @comment = Comment.find(params[:id]) + + akismet_params = { + type: "comment", + text: @comment.body, + created_at: @comment.created_at, + author: @comment.username, + author_email: @comment.email, + author_url: @comment.website, + post_url: url_for(@comment.blog), + post_modified_at: @comment.blog.updated_at, + referrer: @comment.referrer + } + + Akismet.spam @comment.request_ip, @comment.user_agent, akismet_params + + @comment.destroy! + + flash.notice = "Comment successfully marked as spam." + redirect_back pending_admin_comments_url + end + def destroy if Comment.destroy(params[:id]) flash.notice = "Comment successfully deleted." -- cgit 1.4.1