Plugin Developer Discussion

Discussion for FogBugz Plugin developers

Spam Plugin

The built-in Spam button only works for inquiries received through a mailbox that has Autosort enabled. I can't use Autosort, but still need to deal with spam. Rich Armstrong recommended that I write a plugin to address this issue, but I'm not sure what exactly needs to be done to a case to turn it into a "real" spam case. When I press the Spam button I want the case to:

1) Be moved to an area named Spam
2) Not show up in regular searches
3) Be permanently deleted after a few days

As far as I can tell, the only thing the built-in Spam button will do when Autosort is disabled is to close the case with a status of "Resolved (SPAM)". So I'm thinking I can implement IPluginBugCommit.BugCommitBefore to detect when cases are resolved as spam and then change CBug.ixArea to move it to a Spam area. That solves requirement (1), but what magic needs to be done to a case to solve requirements (2) and (3)?
danielm Send private email
Wednesday, January 27, 2010
Hi Daniel-
The cases should be omitted from searches as long as they are in a 'Spam Area' -- that is, an Area whose nType is typeSpam (integer value 3).
Automatic Spam deletion by CDailyTask is best explained by a look at the function: check out src-Website/CDailyTask.was, function DeleteSPAM. The basics are that it:
 - is in a SPAM area (nType=3, as above) or is resolved as SPAM (ixStatus=13)
 - cannot be replied or forwarded
 - is in a mailbox whose nDeleteSpam (number of days to wait before deleting spam) is greater than 0
 - has been around longer than the mailboxes nDeleteSpam
Does that all make sense?
Brett Kiefer Send private email
Thursday, January 28, 2010
Thanks Brett, that all sounds fine. So my only issue is how to get an area with nType=3 when Autosort is off. I guess one of the following would work:

1) Create a fake project with a fake mailbox (i.e. email address that can never receive email), turn Autosort on for that mailbox, and move all spam to that project's Spam area.

2) Create areas named Spam in my regular projects, and then manually change nType=3 in the database.

Or is there a better way to do it?
danielm Send private email
Thursday, January 28, 2010
You could code the plugin to create a new Spam area for the Mailbox you want to use, and set its nType to 3 via the plugin API: that property of CArea is settable.
Brett Kiefer Send private email
Thursday, January 28, 2010
Thanks, sounds good, I think I'll do that.

Suggestion: I found it rather confusing that this Spam stuff did not work when I turned off Autosort. I think it would be nice to have Spam working the same regardless of the mailbox's sorting preference. A solution would be to ALWAYS create the special undeletable Spam area when a mailbox is created, and move spam there when the Spam button is pressed. I see you opened a request for something similar back in 2005, but I guess it was never implemented for some reason:
danielm Send private email
Thursday, January 28, 2010
Agreed, that is confusing, we'll see if we can make that clearer.
Brett Kiefer Send private email
Thursday, January 28, 2010

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz