<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>db/migrate/005_add_mollomid_column.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,5 @@
 class Admin::CommentsController &lt; ApplicationController
-  
+
   def index
     conditions = case params[:status]
     when &quot;approved&quot;
@@ -15,13 +15,13 @@ class Admin::CommentsController &lt; ApplicationController
     else
       @page.comments.paginate(:page =&gt; params[:page], :conditions =&gt; conditions)
     end
-    
+
     respond_to do |format|
       format.html
       format.csv  { render :text =&gt; @comments.to_csv }
     end
   end
-  
+
   def destroy
     @comment = Comment.find(params[:id])
     @comment.destroy
@@ -29,11 +29,11 @@ class Admin::CommentsController &lt; ApplicationController
     ResponseCache.instance.expire_response(@comment.page.url)
     redirect_to :back
   end
-  
+
   def edit
     @comment = Comment.find(params[:id])
   end
-  
+
   def update
     @comment = Comment.find(params[:id])
     begin
@@ -48,7 +48,7 @@ class Admin::CommentsController &lt; ApplicationController
       flash[:notice] = &quot;There was an error saving the comment&quot;
     end
   end
-  
+
   def enable
     @page = Page.find(params[:page_id])
     @page.enable_comments = 1
@@ -56,28 +56,36 @@ class Admin::CommentsController &lt; ApplicationController
     flash[:notice] = &quot;Comments has been enabled for #{@page.title}&quot;
     redirect_to page_index_path
   end
-  
+
   def approve
     @comment = Comment.find(params[:id])
-    @comment.approve!
+    begin
+      @comment.approve!
+    rescue Comment::AntispamWarning =&gt; e
+      antispamnotice = &quot;The antispam engine gave a warning: #{e}&lt;br /&gt;&quot;
+    end
     ResponseCache.instance.expire_response(@comment.page.url)
-    flash[:notice] = &quot;Comment was successfully approved on page #{@comment.page.title}&quot;
+    flash[:notice] = &quot;Comment was successfully approved on page #{@comment.page.title}&quot; + (antispamnotice ? &quot; (#{antispamnotice})&quot; : &quot;&quot;)
     redirect_to :back
   end
-  
+
   def unapprove
     @comment = Comment.find(params[:id])
-    @comment.unapprove!
+    begin
+      @comment.unapprove!
+    rescue Comment::AntispamWarning =&gt; e
+      antispamnotice = &quot;The antispam engine gave a warning: #{e}&quot;
+    end
     ResponseCache.instance.expire_response(@comment.page.url)
-    flash[:notice] = &quot;Comment was successfully unapproved on page #{@comment.page.title}&quot;
+    flash[:notice] = &quot;Comment was successfully unapproved on page #{@comment.page.title}&quot; + (antispamnotice ? &quot; (#{antispamnotice})&quot; : &quot;&quot; )
     redirect_to :back
   end
-  
-  
+
+
   protected
-  
-    def announce_comment_removed
-      flash[:notice] = &quot;The comment was successfully removed from the site.&quot;
-    end
-  
+
+  def announce_comment_removed
+    flash[:notice] = &quot;The comment was successfully removed from the site.&quot;
+  end
+
 end
\ No newline at end of file</diff>
      <filename>app/controllers/admin/comments_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,6 +28,7 @@ class Comment &lt; ActiveRecord::Base
         f.write mollom.server_list.to_yaml
       end
     end
+  rescue Mollom::Error
   end
   
   def mollom
@@ -63,10 +64,14 @@ class Comment &lt; ActiveRecord::Base
           :author_url =&gt; self.author_url,           # author url
           :post_body =&gt; self.content              # comment text
           )
+          ham = reponse.ham?
+          self.update_attibute(:mollom_id, response.session_id)
        response.ham?  
     else
       false
     end
+  rescue Mollom::Error
+    return false
   end
   
   def unapproved?
@@ -83,6 +88,20 @@ class Comment &lt; ActiveRecord::Base
   
   def unapprove!
     self.update_attribute(:approved_at, nil)
+    # if we have to unapprove, and use mollom, it means
+    # the initial check was false. Submit this to mollom as Spam.
+    # Ideally, we'd need a different feedback for
+    #  - spam
+    #  - profanity
+    #  - unwanted
+    #  - low-quality
+     begin
+     if mollom.key_ok? and !self.mollom_id.empty?
+        mollom.send_feedback :session_id =&gt; self.mollom_id, :feedback =&gt; 'spam'
+      end
+    rescue Mollom::Error =&gt; e
+      raise Comment::AntispamWarning.new(e.to_s)
+    end
   end
   
   private
@@ -116,4 +135,6 @@ class Comment &lt; ActiveRecord::Base
       simple_format(h(content))
     end
   end
+  
+  class AntispamWarning &lt; StandardError; end
 end</diff>
      <filename>app/models/comment.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9ff7044e5fac5bad6262d98d31add1ab88ac3a85</id>
    </parent>
  </parents>
  <author>
    <name>franklouwers</name>
    <email>frank@openminds.be</email>
  </author>
  <url>http://github.com/franklouwers/radiant-comments/commit/e3af43df9a895dfdce419f46efd8ee11baa74757</url>
  <id>e3af43df9a895dfdce419f46efd8ee11baa74757</id>
  <committed-date>2008-10-03T08:02:06-07:00</committed-date>
  <authored-date>2008-10-03T08:02:06-07:00</authored-date>
  <message>Comment feedback to mollom: report spam</message>
  <tree>1e7a93f9b53b33d59b801e732bca68780314f7d7</tree>
  <committer>
    <name>franklouwers</name>
    <email>frank@openminds.be</email>
  </committer>
</commit>
