Posted by jmcclelland on February 23, 2009 at 1:36am
Jump to:
| Project: | Mailhandler |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (works as designed) |
Issue Summary
I'm using mailhandler in conjunction with several modules that use the mailhandler hook to process incoming messages.
If none of my modules process the message, I would like mailhandler to ignore the node (rather than attempt to post it as a blog post).
The attached diffs allow users to configure each mailbox with the default node type they would like un-handled messages to be posted as (or optionally set to none, in which case mailhandler will ignore the node).
| Attachment | Size |
|---|---|
| mailhandler.install.optionally-skip-node-creation.patch | 1.1 KB |
| mailhandler.module.optionally-skip-node-creation.patch | 8.54 KB |
Comments
#1
Looks like a valid improvement also for higher versions. So if someone can test it on 5.x and it works we could see to make it a feature request
#2
From my understanding, if your hook_mailhandler() implementation returns NULL, no node or comment is saved at all. Please, review the mailhandler.module file, and search for something like this (it is in 6.x-1.x-dev, but I have no idea when this was introduced)
<?php
// modules may override node elements before submitting. they do so by returning the node.
foreach (module_list() as $name) {
if (module_hook($name, 'mailhandler')) {
$function = $name .'_mailhandler';
if (!($node = $function($node, $result, $i, $header, $mailbox))) {
// Exit if a module has handled the submitted data.
break;
}
}
}
if ($node) {
if ($node->type == 'comment') {
$nid = mailhandler_comment_submit($node, $header, $mailbox, $origbody);
$type = 'comment';
}
else {
$nid = mailhandler_node_submit($node, $header, $mailbox, $origbody);
$type = 'node';
}
}
?>
#3
Well, actually, as this is already fixed in the 6.x version, there is nothing more to do here!