Updated: Comment #10
Problem/Motivation
There are no restrictions on who can command properties, or on what properties they can command. For instance, the default option might be to unpublish nodes for anonymous users, but there's nothing to stop an anonymous user from overriding this if they know to place "status: 1" (or the equivalent command) at the top of the email body.
Proposed resolution
Add a permission to override default commands. This permission would be enabled by default for authenticated users. Possibly add a note to source nodes under the default commands linking to permissions page?
Remaining tasks
See above.
User interface changes
Possibly just a reminder under the default commands pointing to the permissions page.
API changes
Related Issues
Original report by @penguin25
Is it possible to disable parsing the message body for commands, whilst still specifying default commands for logged-in/not-logged-in users, in the IMAP stream parser settings?
I couldn't see any way of doing this, so wrote the attached patch to add such an option to the settings window (it defaults to enabling this feature, so shouldn't break any existing setups). Have I missed the obvious somewhere?
| Comment | File | Size | Author |
|---|---|---|---|
| mailhandler-body-commands-option.patch | 4.1 KB | penguin25 |
Comments
Comment #1
danepowell commentedYou're right, there's no way to do this at the moment. I've been trying to think of a good way to improve the configuration of commands w.r.t. permissions and defaults. Here's the best idea I have so far- on the parser configuration page, a table that looks like...
It's not perfect, but I think it would be a good compromise that handles most people's needs. On the one hand you might say it's not complex enough, since it doesn't allow differentiating beyond just anon/auth users for default values. On the other hand, it could also be made simpler by getting rid of these separate defaults altogether; the only time I can imagine people using this is as shown - to unpublish unauthorized posts. So I'm wondering if we should just have one default, and move the option to unpublish unauthorized posts elsewhere... Additionally instead of having separate permissions for every command, there could just be one permission (as in hook_perm() ) for 'override mailhandler commands'.
Comment #2
danepowell commentedRight now, I am actually leaning towards making it simpler- that would mean removing the separate default commands currently available for anon/auth users, adding a checkbox somewhere to unpublish unauthorized posts, and adding a permission to allow roles to override commands by putting them in the body (enabled by default). Would that work for you?
Comment #3
penguin25 commentedBy "removing the separate default commands current available for anon/auth users", do you mean that a single default commands option would still be available, or do you mean removing the default commands option altogether?
If the single default commands option remained, then your proposal works for me.
Comment #4
danepowell commentedYes, there would just be a single 'default commands' option that would apply to all users.
Comment #5
danepowell commentedHey penguin25- sorry for the delayed response, I've just been working on a lot of other issues.
I've been thinking about this a lot more and I've come to a conclusion. I don't want to make this module any more complicated than it already is, and I'm afraid that slathering on another layer of permissions might do just that. The way I see it, Mailhandler is just an alternative to using the web-based node creation form. Thus, if a module allows you to set default parameters per-role, or restricts certain roles from changing default parameters (i.e. the permissions system), then it should apply to both web-created content and email-created content.
Thus, the Feeds Node Processor should be responsible for applying these defaults and restrictions, not Mailhandler.
I would appreciate hearing your use case so we can brainstorm how this might actually work for you, and what modifications to Feeds might be necessary.
I hope you understand, and I welcome any better ideas, as long as they don't unduly increase the complexity of the module.
(changed the version to 7.x-2.x, as any new features will be developed there first)
Comment #6
penguin25 commentedMy website basically provides an archive of a mailing list, and uses MailHandler to create one node for each message posted to the list. Not everybody who posts to the list has an account on the website, so I want the behaviour for authenticated and anonymous users to be identical. This means:
- status:1 in all cases (nodes are created and published automatically regardless of who posted the message)
- default commands are needed (I set some additional CCK fields in each node to some default values, which can only be subsequently changed by site admins)
- commands in the mail body disabled in all cases (I don't want people making posts to the mailing list to be able to change how the website nodes are created in any way, including the values set by the default commands just described)
All of the above points are covered by your suggestion in comment #2, although the permission to allow different roles to override commands is over-complicated for my needs (I just need to be able to disable the feature, and it's fine for me to do it globally, although I could believe that other people need at least some level of control of this).
For my use case, your statement in comment #5 "Mailhandler is just an alternative to using the web-based node creation form" isn't really the case. On my site, only admins have permission to create/edit/delete the nodes used for the mailing list archive directly using Drupal's normal web interface/permissions system. However, I still need nodes to be created and published automatically whenever anybody posts to the mailing list, regardless of whether they're a site admin, normal site user, or don't even have an account on the site.
Comment #7
danepowell commentedComment #8
calebtr commentedI am glad to see you recently set this to active.
Here is my use case:
My Q+A site allows people to email us questions and replies to our answers. Sometimes the user sends a message where one or more of the lines matches the regexp in MailhandlerCommandsDefault.class.php's getCommands. No "available commands" are set in my importer.
But getCommands doesn't just return the commands in the message, it strips them from the body.
If MailhandlerCommandsDefault.class.php could use getCommands to only get commands instead of to get commands and strip potential commands from the body text, my use case would be satisfied.
Alternatively, offer a raw body field to the importer mappings.
Thanks for considering!
Comment #9
kscheirerSeems like providing a raw body field is the easiest solution?
Comment #10
danepowell commentedI think the best way forward is to add a global permission 'override default commands', and enable it by default for authenticated users. I know some people might like more granular permissions, but I'm hoping this strikes the right balance between complexity and flexibility.
I also changed this to a major bug, because I think it's not clear enough that anonymous users can currently override default commands (such as publishing their own nodes) if they just know the correct command.
Comment #11
nickonom commentedThe patch above seems to be for 6.x and unfortunately the issue still persists in 7.x. I wonder is there any temporary solution to suppress custom commands from displaying in node body?