When I add the og_groups: [2545] command to my mailhander mailbox - it still does not assign the created node to the group.
After some debugging it seems to be in the og_submit_group() function where it has code to 'Normalize the groups' in this property.
Since the actual id (2545 above) comes in as a value in the array - not as a key - the array_keys() function call strips away these values and leaves only the keys - which do not correspond with any groups.
If I remove this array_keys() call - things seem to work fine.
I will be submitting this as a patch shortly - but I wanted to do a quick check to make sure I wasn't missing anything.
Comment | File | Size | Author |
---|---|---|---|
#21 | 136606-21-mailhandler_emailed_content_assign_to_group.patch | 669 bytes | xurizaemon |
#22 | 136606-21-mailhandler_emailed_content_assign_to_group.2.patch | 668 bytes | xurizaemon |
#4 | og.patch | 1.29 KB | struesda |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedwhere's the patch :)
Comment #2
struesda CreditAttribution: struesda commentedok - I'm very much a slacker who got too busy with other things! Here's the patch!
Comment #3
struesda CreditAttribution: struesda commentednevermind - apparently there is a problem with file attachments - I will try again later.
Comment #4
struesda CreditAttribution: struesda commentedtrying to attach the patch again
Comment #5
moshe weitzman CreditAttribution: moshe weitzman commentedthere is some (interesting) extraneous code in og_nodeapi() in the patch. what are you up to :).
i would actually like to attack this differently. i want to make it possible to use associative arrays in mailhandler commands. the syntax for that should be the identical as our .info files. for example, see the $region example at http://drupal.org/node/171205.
so, at the beginning of mailhandler_process_message() we should actually write the contents of the commands variable along with any commands in the email to the temp dir and then pass that filename to drupal_parse_info_file() which will hand back the $data array we need. then we merge with $node and proceed.
AFAICT, the .info syntax is backwards compatible with what we have now so no update is required. nice.
Comment #6
struesda CreditAttribution: struesda commentedNow that I look back at it I see that extra stuff in og_nodeapi() - but I don't remember putting it there! (of course I've slept a lot since then). Perhaps it was something that the og2list README said to put in there - I remember that module required too much manual installation.
The associative arrays ideas sounds big improvement. Would there be a way to add a drupal_parse_info_string() function - rather than incur the overhead of file IO for this kind of thing? I don't know much about the .info code - but I would think that the logic would be the same - just the input source would be different.
UPDATE: I just took a quick peek at the drupal_parse_info_file() code - and it would be pretty easy to:
- move most of the code to a drupal_parse_info_string() function
- change drupal_parse_info_file() to
Then you get both - plus you can easily build other inputs as well (parse_xml..parse_array..parse_db_select ...)
Comment #7
moshe weitzman CreditAttribution: moshe weitzman commentedi think that would be a good improvement for core, but it should not slow down my patch. retrieving messages is a seldom operation and we only have to write the commands once per retrieve so performance is a non issue.
Comment #8
struesda CreditAttribution: struesda commentedSo is this .info feature in drupal 6 only?
If so - then for 4.7/5 do we keep with this version of the patch?
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedno, we have .info in 5 as well. i don't expect any changes for 4.7
Comment #10
artatac CreditAttribution: artatac commentedwatching
Comment #11
ArmandMorin-1 CreditAttribution: ArmandMorin-1 commentedIs this patch applied to the latest release of OG?
Comment #12
cglusky CreditAttribution: cglusky commentedOK. Been at this for more than a few hours now. Trying to get mailhandler to work in D6. Using the og_groups: [x] command was not working until I commented out the line as per the patch above. I am trying to understand what is happening in this function from the latest D6 version of og.module:
Note 1: It seems we are using short hand to cast an objects properties to an array and merge at same time?
Note 2: Then filter the array against what we set earlier, which appears to be designed to remove null values?
Note 3: This is the line that gets commented out so we return values and get it to work with mailhandler.
Sorry if these are such stupid questions but it's late and I am really trying to grok this function.
I know Moshe has plans to work this another way but if this fix works and does not cause unintended consequences it could be a good way for a bunch of us to get by in the short term.
Thoughts please.
Thanks,
Coby
Comment #13
cglusky CreditAttribution: cglusky commentedchanging it to ANMI since I also changed the version to 6. I will create a patch if I can get some confirmation on the implications of the above fix. I have already tested it and know it works in the mailhandler use case.
Comment #14
cglusky CreditAttribution: cglusky commentedHere is what I have so far:
presave is the new submit. It allows a better workflow for modules to perform action(s) prior to save.
This is for a node that may have multiple groups (audiences); some of which may not be available to the current user. This should not be the case for Mailhandler as you will only be allowed to save a node if you have permissions to the group declared in the email command. This is more of an issue on update, so perhaps we have issues if someone is trying to use the subject line to edit the node.
Is useful to get rid of null values. Should not have any if we are using mailhandler. But I guess it's possible.
This is the problem line. As mentioned by @struesda above the keys in this array are not going to be helpful - we want the values. So, was this a way to make sure we have the correct number of dimensions for the object properties? Is this a problem in the way Mailhandler is passing og_groups? Or is this a bug in OG that needs to be patched?
Thanks,
Coby
Comment #15
cglusky CreditAttribution: cglusky commentedline 1447 in og.module
still needs to be commented out to get mailhandler to work with og
Comment #16
awry CreditAttribution: awry commentedMailhandler to og is working for me in 6.9 with the commented out array_keys line, described above. However, all new messages processed by mailhandler are being flagged as Public. Is there a mailhandler command I can use to change this?
Comment #17
Chadwick Wood CreditAttribution: Chadwick Wood commentedYep, just did it myself and it seems to be working. Has anyone figured out why that line needs to be in there?
Comment #18
batje CreditAttribution: batje commentedsubscribe
Comment #19
adamwebb CreditAttribution: adamwebb commentedAdding a mailhandler command
og_public: 0
seems to work for me.
Comment #20
xurizaemonI'm using the following code to set the group IDs as both the key and value of the array, which is how OG likes it to be.
The code I'm using so far is this - you could put it in mymodule_mailhandler() if that makes more sense to you.
Comment #21
xurizaemonEDIT: do not use the patch attached to this comment - it contains a typo, re-posting fixed version in next comment ...
Comment #22
xurizaemonfixed typo, pls review
Comment #23
tallsimon CreditAttribution: tallsimon commentedhas development of this module halted? sounded very promising.
Comment #24
amitaibuOG is now relying on notifications for messages, I'll need to better understand what the patch is trying to accomplish that can be already done.
Also please re-roll patch after fixing coding standards -- http://drupal.org/coding-standards
Comment #25
cglusky CreditAttribution: cglusky commented@amitaibu,
It's been awhile since I have touched any of this code, but when I was active on this issue it was all about inbound mail; thus the Mailhandler in the title. I was using Messaging and Notifications for outbound, but to establish two way email communications for OG you need Mailhandler to process incoming emails (unless that has changed, but I do not think it has) along with what used to be Mail2Web for comment threading when I worked on it.
The issue, in review, is that Mailhandler was passing an array to the above function with the value used in the Mailhandler command that sets the node->og_groups for the mail that will become a post. So each group could have it's own email address to make posts to that group. But og_presave eventually sets the node->og_groups using the keys as values. And I have never been able to figure out why - the comment says it's to "Normalize the array". @grobot describes it well in #20 but I am not sure if his patch is needed since it's fixed if we just comment out the offending line that attempts to set the array values using keys. Still a big mystery to me.
Commenting the line out as in #15 has never caused me any issues on sites running several other contrib modules, but there may be issues with other modules that I do not use that also run through the og_presave function???
R,
C
Comment #26
jasonb815 CreditAttribution: jasonb815 commentedHey guys. Running into the issue above. Trying to have Mailhandler automatically add emails to OG forums and not having any luck. The node gets created, is a forum entry, but doesn't go to the OG forum no matter what I use (tid:, og_group:[], og_groups: []) and even tried commenting out the line above. Unless I'm supposed to do anything special after commenting tha out (clear cache, restarted, etc??), it didn't work. Is there a way to make this work with OG 2?
Thanks!
Comment #27
tallsimon CreditAttribution: tallsimon commentedi'm looking for the same thing, would find this indespensible!
Comment #28
Grayside CreditAttribution: Grayside commentedIn general mailhandler kind of stuff is being handled in dedicated modules. If those modules need a specific feature or bugfix, a new issue please.