Commit e60b2450a75998bc702d521856da59cdfeb5ac45
1 parent
acfbc228
Exists in
master
and in
29 other branches
Plugin API for spam checking on comments
ActionItem2306
Showing
1 changed file
with
44 additions
and
1 deletions
Show diff stats
lib/noosfero/plugin.rb
@@ -226,12 +226,55 @@ class Noosfero::Plugin | @@ -226,12 +226,55 @@ class Noosfero::Plugin | ||
226 | # example: | 226 | # example: |
227 | # | 227 | # |
228 | # def filter_comment(comment) | 228 | # def filter_comment(comment) |
229 | - # comment.reject! if anti_spam_service.is_spam?(comment) | 229 | + # if user_not_logged_in |
230 | + # comment.reject! | ||
231 | + # end | ||
230 | # end | 232 | # end |
231 | # | 233 | # |
232 | def filter_comment(comment) | 234 | def filter_comment(comment) |
233 | end | 235 | end |
234 | 236 | ||
237 | + # This method is called by the CommentHandler background job before sending | ||
238 | + # the notification email. If the comment is marked as spam (i.e. by calling | ||
239 | + # <tt>comment.spam!</tt>), then the notification email will *not* be sent. | ||
240 | + # | ||
241 | + # example: | ||
242 | + # | ||
243 | + # def check_comment_for_spam(comment) | ||
244 | + # if anti_spam_service.is_spam?(comment) | ||
245 | + # comment.spam! | ||
246 | + # end | ||
247 | + # end | ||
248 | + # | ||
249 | + def check_comment_for_spam(comment) | ||
250 | + end | ||
251 | + | ||
252 | + # This method is called when the user manually marks a comment as SPAM. A | ||
253 | + # plugin implementing this method should train its spam detection mechanism | ||
254 | + # by submitting this comment as a confirmed spam. | ||
255 | + # | ||
256 | + # example: | ||
257 | + # | ||
258 | + # def comment_marked_as_spam(comment) | ||
259 | + # anti_spam_service.train_with_spam(comment) | ||
260 | + # end | ||
261 | + # | ||
262 | + def comment_marked_as_spam(comment) | ||
263 | + end | ||
264 | + | ||
265 | + # This method is called when the user manually marks a comment a NOT SPAM. A | ||
266 | + # plugin implementing this method should train its spam detection mechanism | ||
267 | + # by submitting this coimment as a confirmed ham. | ||
268 | + # | ||
269 | + # example: | ||
270 | + # | ||
271 | + # def comment_marked_as_ham(comment) | ||
272 | + # anti_spam_service.train_with_ham(comment) | ||
273 | + # end | ||
274 | + # | ||
275 | + def comment_marked_as_ham(comment) | ||
276 | + end | ||
277 | + | ||
235 | # -> Adds fields to the signup form | 278 | # -> Adds fields to the signup form |
236 | # returns = lambda block that creates html code | 279 | # returns = lambda block that creates html code |
237 | def signup_extra_contents | 280 | def signup_extra_contents |