roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r225414 - in /incubator/roller/trunk/src/org/roller: pojos/WeblogEntryData.java presentation/weblog/TrackbackServlet.java
Date Tue, 26 Jul 2005 23:11:36 GMT
Author: agilliland
Date: Tue Jul 26 16:11:33 2005
New Revision: 225414

URL: http://svn.apache.org/viewcvs?rev=225414&view=rev
Log:
apply blacklist check to incoming trackbacks.

Modified:
    incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java
    incubator/roller/trunk/src/org/roller/presentation/weblog/TrackbackServlet.java

Modified: incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java?rev=225414&r1=225413&r2=225414&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java (original)
+++ incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java Tue Jul 26 16:11:33 2005
@@ -657,6 +657,7 @@
      * @param excerpt
      * @param blogName
      */
+    /* moved to trackback servlet -- Allen G
     public void addTrackback(
         String url, String title, String excerpt, String blogName) 
         throws RollerException
@@ -693,6 +694,7 @@
         //ref.setDateString(formatPubTime("yyyyMMdd"));        
         //mRoller.getRefererManager().storeReferer(ref);
     }
+    */
     
     /**
      * Convenience method for getPermalink(category)

Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/TrackbackServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/TrackbackServlet.java?rev=225414&r1=225413&r2=225414&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/TrackbackServlet.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/TrackbackServlet.java Tue Jul
26 16:11:33 2005
@@ -14,6 +14,11 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.UnsupportedEncodingException;
+import java.sql.Timestamp;
+import java.util.Date;
+import org.roller.model.RollerFactory;
+import org.roller.pojos.CommentData;
+import org.roller.util.CommentSpamChecker;
 
 
 /**
@@ -130,14 +135,38 @@
                 
                 if (entry!=null && entry.getCommentsStillAllowed())
                 {
-                    entry.addTrackback(url,title,excerpt,blogName);
-                    rreq.getRoller().commit();
-            
-                    pw.println("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
-                    pw.println("<response>");
-                    pw.println("<error>0</error>");
-                    pw.println("</response>");
-                    pw.flush();
+                    String modTitle = blogName + ": "  + title;
+                    if (modTitle.length() >= 250) {
+                        modTitle = modTitle.substring(0, 257);
+                        modTitle += "...";
+                    }
+                    
+                    // Track trackbacks as comments
+                    CommentData comment = new CommentData();
+                    comment.setContent("[Trackback] "+excerpt);
+                    comment.setName(blogName);
+                    comment.setUrl(url);
+                    comment.setWeblogEntry(entry);
+                    comment.setNotify(Boolean.FALSE);
+                    comment.setPostTime(new Timestamp(new Date().getTime()));
+                    
+                    // check if this is spam
+                    CommentSpamChecker checker = new CommentSpamChecker();
+                    checker.testComment(comment);
+                    if (comment.getSpam().booleanValue()) {
+                        error = "Trackback spam!";
+                        
+                    } else {
+                        // save, commit, send response
+                        comment.save();
+                        RollerFactory.getRoller().commit();
+                        
+                        pw.println("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
+                        pw.println("<response>");
+                        pw.println("<error>0</error>");
+                        pw.println("</response>");
+                        pw.flush();
+                    }
                 }
                 else if (entry!=null)
                 {



Mime
View raw message