I'm working on setting up mailcomment support, specifically for replying to Tasks from Work Tracker via e-mail.

However, other plugins in Open Atrium could also use Drupal comments and replying via e-mail might be desirable!

This is issue to implement support for mailcomment and Drupal comments on any node type in the OA Mailhandler module.

Code

I'm working on this in the mailcomment-2113257 branch:

http://drupalcode.org/project/oa_mailhandler.git/shortlog/refs/heads/mai...

Other required patches to Open Atrium

Comments

mpotter’s picture

Yes, I think that would be a great addition to this module.

Be sure to take a look at how the Feeds plugin parses the nid token in the subject line for security purposes. The token is currently supplied by oa_discussion which might not be the correct place for that. We might want to move the security token into oa_core so other plugins can take advantage of it if you make mailhandler more general purpose.

dsnopek’s picture

Great, thanks! I'll post a patch here for review when I've got something ready.

dsnopek’s picture

Title: Include support for mailcomment and Drupal comments? » Include support for mailcomment and Drupal comments

I've begun working on this in the mailcomment-2113257 branch:

http://drupalcode.org/project/oa_mailhandler.git/shortlog/refs/heads/mai...

This will currently only work for Work Tracker, because no other content types will create messages for comments, even if they are enabled for the content type. Here is a patch to oa_messages to correct that: #2115919: Add 'oa_comment' message type for comments (will be used by oa_mailhandler)

The mailcomment_message_notify module won't work for us because it makes assumptions about the field names. :-( This meant that I had to copy a lot of what it does in hook_mail_alter() into oa_mailhandler. However, we could make the code more generic so that it'll be used for OA Discussion as well!

What do you think of:

  • Adding the security token in oa_mailhandler_mail_alter() rather than as a token in the message object. This way users can accidentally remove it AND we can use it for comments too.
  • Using the mailcomment settings and message mangling in oa_mailhandler_mail_alter() for OA Discussion Post too. So, we'll get the subject mangling, "reply above this line" parsing, unified variables for mailcomment_mail and mailbox_mail, etc.

See oa_mailhandler_mail_alter() to get a better idea of what I mean:

http://drupalcode.org/project/oa_mailhandler.git/blob/refs/heads/mailcom...

Please let me know what you think!

dsnopek’s picture

Revision 08f5d90 does the same security token for Drupal comments as is used for OA Discussion, except it's all self contained in OA Mailhandler.

I think I'm going to go ahead and attempt to unify the handling of Drupal comments and OA Discussion and get everything self-contained in OA Mailhandler like I described in comment #3, so that you have something concrete to review. If it turns out that you don't want to go this direction, I can always revert back to revision 08f5d90.

Some more patches to other parts of Open Atrium will be necessary - I'll gather links to them all in the issue description.

mpotter’s picture

I've committed the patch for the comment message type.

dsnopek’s picture

@mpotter: Awesome, thanks! That's really the biggest one. The rest will be removing functionality as it gets moved into OA Mailhandler.

dsnopek’s picture

Issue summary: View changes

Cleaned up issue description and included links to current work!

dsnopek’s picture

Issue summary: View changes

Adding another dependent patch.

dsnopek’s picture

Issue summary: View changes

Added another dependent issue.

dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new20.47 KB

Ok! This now ready for review. It completely unifies comment and discussion "reply by email" functionality, and moves everything to be self-contained within the OA Mailhandler module (rather than spread among oa_messages and oa_discussion as well).

You can find the code in the "mailcomment-2113257" branch in Git:

http://drupalcode.org/project/oa_mailhandler.git/shortlog/refs/heads/mai...

(I've attached a patch to make review easier if you prefer to look at patches - however, it'd probably be best to actually merge the branch in Git rather than applying the patch.)

Also, these are the dependent patches (to oa_core and oa_discussion) to allow this to work fully correctly, although it doesn't necessary fail without them - somethings are simply done twice:

Please let me know what you think!

@mpotter: I can do the actual branch merging if you like, I'd just prefer your approval before making such a big change. :-)

dsnopek’s picture

StatusFileSize
new20.33 KB

Er, not that it matters because we'll merge the branch, but I found some cruft while quickly reading through that patch. Here is a new patch with the cruft removed.

mpotter’s picture

Status: Needs review » Reviewed & tested by the community

I think this looks good. Go ahead with the branch merge and I'll commit those other patches to oa_core and oa_discussion. Nice job refactoring all of this!

mpotter’s picture

Patches in #7 have been committed.

dsnopek’s picture

Status: Reviewed & tested by the community » Fixed

Awesome, thanks! Merged in revision f6e55a7. :-)

dsnopek’s picture

Issue summary: View changes

Added another dependent patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.