Skip to content

don't overwrite contact ID when trigger is contact-based

JonGold requested to merge JonGold/emailapi:fix-contact-id-overwrite into master

This fixes an old regression from !3 (merged).

MR !3 (merged) passes the id of the entity that triggered a rule into Email.send. E.g. if the trigger is a contribution, we pass the contribution ID in - so we can process contribution tokens.

However, $params['contact_id'] represents the recipient of the email, and should not be overwritten. When using a rule like "Send to Related Contact" or "Send to Roles on Case", where the contact ID that triggered the rule isn't the same as the recipient, this changes the recipient. So "Send to Related Contact/Roles on Case" functions identically to "Send to Contact" when the contact is trigger-based.

Steps to replicate

  • Create a new rule with a trigger of "Contact is changed" and an action of "Send Rule to Related Contact".
  • Go to a contact that has a relationship matching the one specified in the rule.
  • Edit the contact

Expected Behavior

Email goes to related contact.

Actual Behavior

Email goes to contact that triggered the rule.

Merge request reports

Loading