Commit 9e4102e25b79d7142a9f822f6c4cc07a9e2ba0b6
1 parent
c611bd07
Exists in
master
and in
8 other branches
Remove useless hotspot
That idea could be useful for streaming comment data, but it is not useful to notify plugins that a comment was saved before checking e.g. that it is not SPAM. So this notification must be done by the CommentHandler class, *after* it decided that the comment received is valid (e.g. an antispam plugin decided it is not spam). ActionItem2306
Showing
3 changed files
with
0 additions
and
32 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
... | ... | @@ -123,7 +123,6 @@ class ContentViewerController < ApplicationController |
123 | 123 | plugins_filter_comment(@comment) |
124 | 124 | return if @comment.rejected? |
125 | 125 | if (pass_without_comment_captcha? || verify_recaptcha(:model => @comment, :message => _('Please type the words correctly'))) && @comment.save |
126 | - plugins_comment_saved(@comment) | |
127 | 126 | @page.touch |
128 | 127 | @comment = nil # clear the comment form |
129 | 128 | redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] |
... | ... | @@ -138,12 +137,6 @@ class ContentViewerController < ApplicationController |
138 | 137 | end |
139 | 138 | end |
140 | 139 | |
141 | - def plugins_comment_saved(comment) | |
142 | - @plugins.each do |plugin| | |
143 | - plugin.comment_saved(comment) | |
144 | - end | |
145 | - end | |
146 | - | |
147 | 140 | def pass_without_comment_captcha? |
148 | 141 | logged_in? && !environment.enabled?('captcha_for_logged_users') |
149 | 142 | end | ... | ... |
lib/noosfero/plugin.rb
... | ... | @@ -232,12 +232,6 @@ class Noosfero::Plugin |
232 | 232 | def filter_comment(comment) |
233 | 233 | end |
234 | 234 | |
235 | - # This method will be called just after a comment has been saved to the | |
236 | - # database, so that a plugin can perform some action on it. | |
237 | - # | |
238 | - def comment_saved(comment) | |
239 | - end | |
240 | - | |
241 | 235 | # -> Adds fields to the signup form |
242 | 236 | # returns = lambda block that creates html code |
243 | 237 | def signup_extra_contents | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -1395,25 +1395,6 @@ class ContentViewerControllerTest < ActionController::TestCase |
1395 | 1395 | end |
1396 | 1396 | end |
1397 | 1397 | |
1398 | - should 'notify plugins after a comment is saved' do | |
1399 | - class TestNotifyCommentPlugin < Noosfero::Plugin | |
1400 | - def comment_saved(c) | |
1401 | - @__saved = c.id | |
1402 | - @__title = c.title | |
1403 | - end | |
1404 | - attr_reader :__title | |
1405 | - attr_reader :__saved | |
1406 | - end | |
1407 | - plugin = TestNotifyCommentPlugin.new | |
1408 | - Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([plugin]) | |
1409 | - page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text') | |
1410 | - post :view_page, :profile => profile.identifier, :page => [ 'myarticle' ], :comment => { :title => 'the title of the comment', :body => 'body', :name => "Spammer", :email => 'damn@spammer.com' }, :confirm => 'true' | |
1411 | - | |
1412 | - assert_equal 'the title of the comment', plugin.__title | |
1413 | - assert plugin.__saved | |
1414 | - | |
1415 | - end | |
1416 | - | |
1417 | 1398 | should 'remove email from article followers when unfollow' do |
1418 | 1399 | profile = create_user('testuser').person |
1419 | 1400 | follower_email = 'john@doe.br' | ... | ... |