It would be great if OG added mailman style List-Id headers to the notifications it sends via email. This would allow users to filter emails (GDO emails in particular, hence the patch for 6.x-2.x) using their MUAs normal list header filters.
The attached patch can create a list-id type representation of an organic group and adds this reprsentation in the List-Id header on outgoing emails.
For example, http://groups.drupal.org/node/217939 would become: node.217939.groups.drupal.org and http://groups.drupal.org/australia would come australia.groups.drupal.org.
The patch also provides this generated string via a token.
Comments
Comment #0.0
cafuego commentedUpdated issue summary.
Comment #1
gregglesTagging. This is a common request I'd love to see get deployed.
There's a chance we'll get a review for this related to gdo or Commons.
Comment #2
Grayside commentedNothing against it, though I'm surprised this should be handled by OG and not more on the Notifications/Messaging side. This awaits review by someone more involved with Notifications and/or mail systems.
Comment #3
cafuego commentedI don't know that it would make sense to add mail headers outside of the scope of OG, unless you're suggesting an API call in Notifications/Messaging that OG (and other modules) would call to set specific headers.
Comment #4
Grayside commentedYeah, that's all I was especially imagining. Like I said, largely waiting for others to RTBC this issue.
Comment #5
cafuego commentedUpdated patch. The actual group identifier is now generated in a helper and the list-id header is constructed in a wrapper function. I could be convinced that the identifier construction should in fact be a theme function, so it can be overridden.
og_notifications now checks if a List-Id header is already present and appends its own string if so.
Comment #6
realityloop commentedThis looks good to me apart from one small thing to meet the coding-standards:
Add newline at end of file http://drupal.org/coding-standards#indenting
can't wait to see this on g.d.o
Comment #7
cafuego commentedAdded newline (told vim to not remove it, anyway ;-) and changed the _og_listid() helper into a theme function, so users can override it.
Comment #8
Grayside commentedComment #9
cafuego commentedIn this case, because I've also provided a token, which could be used outside that context. Not that it makes a whole lot of sense, but og already had a hook_token implementation, so it was easier to add this there :-)
Sure, I'm not fussed either way, as per reason above.
I could see someone not wanting to have per-group custom List-Ids or have them named differently, perhaps with a different hostname part than is returned url(). having a theme function the user can override seems an easier alternative than providing an admin UI for a tokenised string to be used instead. Not allowing it to be customised seems ... mean ;-)
Comment #10
Grayside commentedHi Cafuego,
Let me start by saying I really appreciate your effort here. I totally understand the complexities of wrangling email, and if a little header makes peoples lives easier, I am all for it. That said...
hook_mail_alter()exists if someone wants to tweak it further.If it really needs OG-friendly customizability, I suggest using a token-enhanced textfield to the OG Notifications UI, with an extra post-processing stage to wrangle spaces and other undesireable characters.
Comment #11
cafuego commentedRight then, updated patch. The changes are now all only in og_notifications.module, which does now implement token hooks. The actual list-id value is no longer generated via a theme function.
Comment #12
alexweber commentedThis looks and works great! Can we get this comitted and also forward-ported to 7.x?
Comment #13
cafuego commented7.x no longer uses messaging to send notifications, instead it uses Rules. I've been flighting it today to see what would be needed to get it to insert the same header. I have as yet been unable to make OG 7.x send an email of any sort, so I don't know what/if/how to add a header yet.
Comment #14
alexweber commented@cafuego, no luck with hook_mail_alter() ?
Comment #15
cafuego commentedMaybe, not until I can get it to send mail :-)
Comment #16
alexweber commentedhehe good catch :) what's the issue, the rules integration? I've been doing a lot of stuff with rules lately and wouldn't mind taking a stab at this when I get some time!
Comment #17
cafuego commentedWhen I did the OG 7.x-1.x install to play with, I didn't have Rules enabled. When I did later enabled Rules, the OG default rules weren't detected, so I decided to remove OG and start again. That made be run into a bunch errors caused by Entity (need to make a patch for those too now).
Anywho, I appear to be unable to create a rule that sends an email when a *comment* is posted on an OG node. I *think* I have the correct variables etc set up, the rule is no longer complaining about incorrect/invalid variables, but no email is sent (postfix is set up and working fine on this box). Exported below, see how you go :-)
Comment #18
Grayside commentedThis is looking good. A few nitpicks.
Can stop with the hook signature. Of course it's for OG Notifications :)
Is there a particular reason this default is significant? If not, remove comment. If so, add detail and a period.
Capitalization inconsistency for List-ID
Space above @return. Lower case "string".
Space before and after a period.
Comment #19
cafuego commentedUpdated patch with all issues above (and some besides) addressed.
Fixed up other period concatenation spacing, ensured that hook_token_list always returns an array and added a link to the List-Id RFC document in the doc block of the function that generates it.
Comment #20
Grayside commentedAwesome! Thank you so much for bearing with me on these nitpicks. Two final issues and then I think I'll be ready to commit.
Please use D6 coding standards. "Implementation of".
What does "top group" refer to?
Comment #20.0
Grayside commentedUpdated issue summary.
Comment #21
claudiu.cristeaThis version of Drupal is not supported anymore. If this is still an issue in the
8.x-1.xbranch, please open a new up-to-date ticket. Closing.