I'm Keyvan Nayyeri, a 25 years old Ph.D. student at
the Computer Science department of
the University of Texas at San Antonio.
I'm also
a Software Architect and Developer and previously held a B.Sc.
degree in Applied Mathematics.
This is my blog where I publish content about various topics specifically Programming Languages and Compilers, Software
Engineering and Programming.
As long as Graffiti gets older, it gets targeted by more spammers everyday. For spam protection, I use my own Waegis service and it has worked great to identify and block spams (am I advertising?!).
However, one problem that I noticed recently is the growing number of spams so the increasing number of notification emails that I receive for nothing! Believe me, it’s really annoying to receive many emails that notify you of an obvious spam comment. Unfortunately the default behavior of Graffiti is to send or not send email notifications and you can’t configure and override this behavior at a lower level.
When I started Waegis, Rob Bazinet suggested me to work on this and override the behavior because he had difficulties with the same problem. Though, I didn’t work on it till today when I really noticed its necessity at least for myself!
So I wrote a simple Graffiti plug-in that after installation, overrides this default behavior and stops Graffiti from sending email notifications for spam feedback.
The technique is very simple: Comment class in the Graffiti API has a DontSendEmail property that can be used to override the default notification behavior and disable it on fly. I have to give credit back to Brian Zalk who first introduced me to this property.
Having this property, I can write a short code that overrides the default notification behavior for spam feedback.
using System;
using System.Collections.Generic;
using System.Text;
using Graffiti.Core;
using System.Configuration;
namespace SpamCommentNotifier
{
public class SpamComment : GraffitiEvent
{
#region EditableForm members
public override string Name
{
get
{
return "Spam Comment Notifier";
}
}
public override string Description
{
get
{
return "A plug-in to disable email notifications for spam comments " +
"by <a href=\"http://nayyeri.net\"> Keyvan Nayyeri</a>.";
}
}
public override bool IsEditable
{
get
{
return false;
}
}
#endregion
#region GraffitiEvent members
public override void Init(GraffitiApplication ga)
{
ga.BeforeInsert += new DataObjectEventHandler(ga_BeforeInsert);
}
void ga_BeforeInsert(DataBuddyBase dataObject, EventArgs e)
{
Comment feedback = dataObject as Comment;
if (feedback != null)
{
int threshold = int.Parse(ConfigurationManager.AppSettings["Graffiti:Spam:Score"]);
if (feedback.SpamScore >= threshold)
feedback.DontSendEmail = true;
}
}
#endregion
}
}
There is only one point about Graffiti:Spam:Score item in Web.Config: this application setting is an integer value that is used as a threshold to distinguish spam and legitimate feedback and you can always alter it. However, I found that the default value (10) is good as is!
You can download the binary and source code of this plug-in from here.
Rob Bazinet
Aug 31, 2008 11:39 PM
#
Hey Keyvan, great plugin. I am happy you have found the same issues important and I have.
Thank you for making the plugin.
Keyvan Nayyeri
Sep 01, 2008 8:11 AM
#
@Rob:
You're welcome :-)
Leave a Comment