for the purpose of re-importing and not deleting duplicates... can we depend on this module as well
http://drupal.org/project/unique_field
Mapping for Node processor
Define which elements of a single item of a feed (= Sources) map to which content pieces in Drupal (= Targets). Make sure that at least one definition has a Unique target. A unique target means that a value for a target can only occur once. E. g. only one item with the URL http://example.com/story/1 can exist.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | Capture.JPG | 37.14 KB | bakr |
Comments
Comment #1
bakr commentedI have created a helpdesk node-type in drupal to serve a service ticket form. with some workflow stuff.
I came to use mailhandler to enable automatic creation of tickets through email. works good!
I do not want to delete the message from server after importing it into drupal, thus I have un-ticked delete from server option...
The downside, In effect so far... whenever I re-import, the same ticket gets a new node id and thus duplication and triplication and quadriplication takes place. (English renascence!!)
How would I make use of the "unique target" to avoid duplicates, the examples quoted above did not describe how would I relate to my scenario.
Thanks in advance.
Comment #2
danepowell commentedAre you using POP or IMAP?
Comment #3
danepowell commentedComment #4
bakr commentedSorry for late answer, am back to office!
The answer is: POP3
Comment #5
danepowell commentedHere's what I would be willing to do- write a command plugin that provides the UIDL (unique message id) as a mapping source. Then you could use the CCK unique field module (or whatever module you want) to prevent existing nodes from being re-imported.
The only problem with this is that Mailhandler will continually fetch every message in the inbox, although the message will not actually be posted if you use the CCK unique field module. This will add quite a bit of overhead to cron runs.
Solutions would be to switch to IMAP, ensure that there's never too many messages in the POP inbox, or write a filter plugin that performs the same function as the command plugin I describe above (filtering messages by whether they have already been imported or not- this would require a module that creates a message-tracking table and provides the filter plugin to Mailhandler). I don't have the resources to write such a filter plugin at the moment, but I would accept patches or sponsorship for it.
Comment #6
danepowell commentedComment #7
danepowell commentedWait a minute, the message_id is already provided, so you don't need a new command plugin- have you tried simply mapping the message_id to a unique target?
Comment #8
bakr commentedLet us try to simplify the whole approach.
Let us temporarily forget about the unique field module.
Let me reframe my question as follows:
"What are the ABC steps that I need to follow in order to Utilize the potentially existing features of mailhandler NOT to Re-import the Read(past participle) messages from the IMAP mailbox"
Clearly I have some doubts about the Unique fields option, for example, the way I view it being not logical to map a Mssg_ID(source) to a NodeID(Target) ... this will create a funny node_ID number! Would it?
So how is the best way to re-explain the following statement with a more practical example:
Make sure that at least one definition has a Unique target. A unique target means that a value for a target can only occur once. E. g. only one item with the URL http://example.com/story/1 can exist.Thanks Dane.
Comment #9
bakr commentedhere is my current mapping snapshot.
I think your answer to the above question should go later as direct documentation enhancement to this great module.
Comment #10
danepowell commentedLike I mentioned above, the best solution is to use IMAP: if you do, then messages will automatically be marked as read when they are imported, and they will only be re-imported if you or someone else mark them as unread.
If you must stick with POP, or if there's a possibility that messages will be marked as unread (and thus re-imported), then you should create a CCK field on the target node type named "Message ID". Then map the message ID source (provided by Mailhandler) to the Message ID target (provided by CCK), and mark it as "unique".
Finally, if this mailbox is going to have quite a few messages in it, then consider writing a filter plugin / module for Mailhandler that stores read message IDs in a custom DB table, and prevents them from being re-imported.
Does that make sense?
Action items for this issue: summarize and add to documentation, spin off feature request for filter plugin to work with POP mailboxes to prevent re-importation of messages.
Comment #11
bakr commentedWow, that rounds the robbin, now it makes perfect sense, as these little info were a bit vague for novice. now it is more explicit.
Thanks again Dane for the great support and expanations. it is clear now.
Bakr
Comment #12
bakr commentedOne little clarification :)
in the following quote:
is the "Message ID" a keyword, as such the cck field name would be "field_message_id" or is it just a generic field that can be given any name???
sorry to get my head again around this :|!
Bakr
Comment #13
danepowell commentedI just mean that you should create a CCK text field- you can give it any name you want. What's important is that when you configure the processor mapping (at
admin/build/feeds/edit/mailhandler_nodes/mapping), you map the "Message ID" source to the CCK field that you create, and mark the mapping as unique.Comment #14
danepowell commentedHere's the spin-off issue: #1343606: Option to prevent re-importation of messages
I added documentation:
http://drupal.org/commitlog/commit/96/52ab7bfc6a9996f7931b9ff3f73c110cb7...
http://drupal.org/commitlog/commit/96/e8bbec42277984dbc1248a938c62718ef1...
Finally, here is an issue to create a new content type / default importer that will demonstrate how to use the unique message ID mapping... #1343630: Change 'Mailhandler Default' to 'Mailhandler quick-start' and improve usability
Comment #15
danepowell commented