Please add a type of recipient / reply-to email chosen from a contextual user.

Example a a curren node that is being viewed has a form block attached on the side, the recipient will be node->author->mail.
Same for any other entity that has a basic field definition uid as user reference.

CommentFileSizeAuthor
#9 3049425-9.patch5.97 KBeglaw
#7 3049425-7.patch7.27 KBeglaw
#2 3049425-1.patch5.2 KBeglaw
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

eglaw created an issue. See original summary.

eglaw’s picture

StatusFileSize
new5.2 KB

Here's a patch that adds this feature

scott_euser’s picture

I wonder if this is something that can be achieved already with a hidden field in the form housing a token value?

That said not against this but needs tests (and of course existing tests to pass).

scott_euser’s picture

Status: Active » Needs work
Issue tags: +Needs tests
eglaw’s picture

@scott_euser ... agree, probably it can, but no way you'll do it without any preprocessing the form on the example Node (or other) page and hiding the field or altering it into a hidden type ...

I'll check into the failing test later

eglaw’s picture

That said not against this but needs tests (and of course existing tests to pass).

@scott_euser by that you mean that it should pass a deprecated type of SimpleTest class? Well it does a part from 1 test only:

Drupal\contact_emails\Tests\Update\ContactEmailsTableToEntityUpdateTest

which will NEVER pass as far as it tries to make a query on a NOT existing table (contact_message_email_settings), probably a reminiscense of a drupal7 version of this module.



Being said that ... what test would you like this patch includes ? The same simpletest ones as for ContactEmailsRecipientTest or ContactEmailsRecipientReferenceTest?
Keep in mind that a SimpleTest tests are deprecated and will be droped in Drupal 9.x.

eglaw’s picture

StatusFileSize
new7.27 KB

Reworked the patch a little:
Added the transformation of the contact_message into a personal one, if the recipient_type on email config is context

scott_euser’s picture

Thanks for the work on this! Better to go straight for a non-deprecated test. Will create a separate issue for Drupal 9 support.

eglaw’s picture

StatusFileSize
new5.97 KB

Formatted a new patch for the contact_emails-8.x-1.18 version

Enjoy :)

AstonVictor made their first commit to this issue’s fork.

astonvictor’s picture

Assigned: eglaw » astonvictor
Status: Needs work » Needs review

Created a new MR.

My steps for testing:
1. Created a new node type. e.g. Mail.
2. Created a new contact form on /admin/structure/contact/add page:
- label - context test
- recipients - test@test.com
- message - my message
3. Created a new contact email on /admin/structure/contact/emails/add page:
- contact form - context test
- subject - context test
- recipient type - The context entity author's email
4. Installed Contact Block module.
5. Added the block with the contact form with visibility - content type = Mail
6. Created a new mail node as user1.
7. Submitted the contact form on the node page as user2.

result: a new mail was sent to the user1.

The pipeline works fine and there are no failures in tests.
I'm not sure if we should add a new test because it requires adding an additional contrib module as a dependency for only one specific case.

Note that if the route contains a few parameters/entities of EntityOwnerInterface interface then the mail will be sent to all owners.

astonvictor’s picture

Version: 8.x-1.16 » 8.x-1.x-dev
Assigned: astonvictor » Unassigned
Status: Needs review » Fixed

Merged the MR.

Status: Fixed » Closed (fixed)

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