about summary refs log tree commit diff stats
path: root/app/controllers
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-03-20 10:49:38 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-03-20 10:49:38 -0400
commit2e1365d37bddf787c7089126c1a5ff1c623ab0e2 (patch)
treeb28ebb51e4070bfafea486984ca8e393a378f84c /app/controllers
parentc319edf970b238cfc795f54e44de41ddab48ea71 (diff)
downloadthoughts-2e1365d37bddf787c7089126c1a5ff1c623ab0e2.tar.gz
thoughts-2e1365d37bddf787c7089126c1a5ff1c623ab0e2.tar.bz2
thoughts-2e1365d37bddf787c7089126c1a5ff1c623ab0e2.zip
Added mass pending comment deletion/markspamming
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/comments_controller.rb53
1 files changed, 37 insertions, 16 deletions
diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 6b4bff3..4d9502d 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb
@@ -33,22 +33,7 @@ class Admin::CommentsController < Admin::AdminController
33 33
34 def mark_spam 34 def mark_spam
35 @comment = Comment.find(params[:id]) 35 @comment = Comment.find(params[:id])
36 36 perform_mark_spam(@comment)
37 akismet_params = {
38 type: "comment",
39 text: @comment.body,
40 created_at: @comment.created_at,
41 author: @comment.username,
42 author_email: @comment.email,
43 author_url: @comment.website,
44 post_url: url_for(@comment.blog),
45 post_modified_at: @comment.blog.updated_at,
46 referrer: @comment.referrer
47 }
48
49 Akismet.spam @comment.request_ip, @comment.user_agent, akismet_params
50
51 @comment.destroy!
52 37
53 flash.notice = "Comment successfully marked as spam." 38 flash.notice = "Comment successfully marked as spam."
54 redirect_back fallback_location: pending_admin_comments_url 39 redirect_back fallback_location: pending_admin_comments_url
@@ -64,9 +49,45 @@ class Admin::CommentsController < Admin::AdminController
64 redirect_to admin_comments_url 49 redirect_to admin_comments_url
65 end 50 end
66 51
52 def mass
53 if params[:mass_action] == "Delete"
54 Comment.destroy_by(id: params[:comment_ids])
55
56 flash.notice = "Comments successfully deleted."
57 elsif params[:mass_action] == "Mark Spam"
58 @comments = Comment.find(params[:comment_ids])
59
60 @comments.each do |comment|
61 perform_mark_spam(comment)
62 end
63
64 flash.notice = "Comments successfully marked as spam."
65 end
66
67 redirect_back fallback_location: pending_admin_comments_url
68 end
69
67 private 70 private
68 71
69 def set_section 72 def set_section
70 @section = "comments" 73 @section = "comments"
71 end 74 end
75
76 def perform_mark_spam(comment)
77 akismet_params = {
78 type: "comment",
79 text: comment.body,
80 created_at: comment.created_at,
81 author: comment.username,
82 author_email: comment.email,
83 author_url: comment.website,
84 post_url: url_for(comment.blog),
85 post_modified_at: comment.blog.updated_at,
86 referrer: comment.referrer
87 }
88
89 Akismet.spam comment.request_ip, comment.user_agent, akismet_params
90
91 comment.destroy!
92 end
72end 93end