Blogsphere - Delete "Fake" Responses agent
Category BlogSphere
Bookmark :
Lately I have been getting more and more "fake" responses created in my blog - these are responses created by spammers that are created without any "parent" document (i.e. they don't have a $REF field, etc.). They appear at the top of my Stories view, and they simply annoy me because I have to delete them all the time. So, I decided to write an agent to delete them for me - and I figured that others must be experiencing the same problem, so I thought I would share the agent here.
It is a really small agent - here's all the code:
Sub Initialize Dim s As New NotesSession Dim thisdb As NotesDatabase Dim col As NotesDocumentCollection Dim doc As NotesDocument,deldoc As NotesDocument On Error Goto errHandler Set thisdb = s.CurrentDatabase Set col = thisdb.UnprocessedDocuments If col.Count = 0 Then Exit Sub Set doc = col.getFirstDocument Do While Not(doc Is Nothing) If doc.GetItemValue("Form")(0) = "StoryResponse" Then If doc.HasItem("$REF") = False Then Set deldoc = doc End If End If Call s.UpdateProcessedDoc(doc) Set doc = col.GetNextDocument(doc) If Not(deldoc Is Nothing) Then Call deldoc.Remove(True) Loop getOut: Exit Sub errHandler: Msgbox Error$ & " (" & Err & ") [line: " & Erl & " in DeleteFakeResponses agent]",, "Error" Resume getOut End Sub
Not much to it. The agent is scheduled to run "after documents are created or modified", and is set to run on my blog server. It gets a collection of unprocessed documents, then loops through all of them. It first checks the form to see if it is "StoryResponse", and if it is then it checks to see if it has a $REF item. If it does not, the doc is set to a deldoc handle, and is deleted after the next document handle is gotten (so that it loops correctly).
I tested it, and I am running it now with great success. Hopefully it will help you too.
Enjoy!
Rock
**Mr. Scott, there are always alternatives. --Mr. Spock, Star Trek









Blog Roll










Comments
Posted by Duffbert At 10:56:59 PM On 02/08/2006 | - Website - |
Posted by Rob McDonagh At 09:43:35 AM On 02/09/2006 | - Website - |
Posted by Richard Schwartz At 07:00:07 PM On 02/08/2006 | - Website - |
Dang, this is very nice ...simple and elegant.
A year (probably 2 yrs) ago I modified the agent in my Blogsphere db that notifies me when new comments are posted. I added some code that deletes the doc if it meets certain criteria (like no body text, no contact info, etc), AND I have it still notify me via email with the IP or whatever other info is available. I also added a line in the notification email that I can click to invoke an agent to delete the comment if it's obvious from the email address, IP, or site URL of the sender that it's bogus. The point is that it may still be useful to track the ip and/or other info.
I think I'll take your code and incorporate it. I'll try and make time in the next day or three to post the merged code (or email it to you :) re the delete agent and linking from the notification email (it's of course, painfully simple, not too elegant, etc., etc.).
Posted by Joe Litton At 10:42:54 AM On 02/09/2006 | - Website - |
Posted by Gerco Wolfswinkel At 04:44:37 AM On 02/09/2006 | - Website - |
You read my mind. Thanks for this agent code.
Bruce
Posted by Bruce Elgort At 01:33:40 PM On 02/10/2006 | - Website - |
Posted by Christian Brandlehner At 10:30:35 AM On 02/13/2006 | - Website - |
Posted by Scott Good At 09:03:15 AM On 02/13/2006 | - Website - |