Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extension hook to control file attachments per recipient and field #1252

Conversation

michalkleiner
Copy link
Contributor

As per the title, adding an extension hook where developers can control if an uploaded file should be attached to an email, for each recipient and each upload field separately.

This will allow for further control e.g. for extensions that control email attachments per upload field (some could be sent, some shouldn't) or per recipient (internal staff, external processors etc.) and other combinations.

The list of attachments is not changed at this point as it's required for other extension hooks on the whole email where the access to recipients or email attachments is not possible (especially with Symfony Email once attachment is added it can't be easily removed).

Ref. #1203

As this is adding new extension point it's targeting 6 for 6.2.0 but if we saw that as a partial way how to address e.g. the issue where CMS recipients may not have access to the file then I'd be happy to retarget and get it out in a patch as soon as practical to avoid using the fork for now.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your views on dynamically adding a checkbox to the recipient edit form for each upload field on the form instead (or potentially as well, if you can think of other use-cases for this hook) of using an extension hook here?

@michalkleiner
Copy link
Contributor Author

That is surely one way how to achieve one thing (control if a recipient should receive a file from a specific upload field), but could feel cumbersome in a way that you need to always go add the upload field and then edit all recipients to check/uncheck the checkbox. Or (if it was managed at the field side) edit all fields when recipients are added. Doable, but doesn't feel ideal.

The hook doesn't prevent doing the above via an extension, plus offers more flexibility and allows project developers to implement their own business rules around this, e.g. check if the recipient is also a CMS editor, check if the form is sent to a "always CC" address and so on.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just one suggestion

code/Control/UserDefinedFormController.php Show resolved Hide resolved
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GuySartorelli GuySartorelli merged commit 4b85a33 into silverstripe:6 Nov 12, 2023
12 checks passed
@michalkleiner michalkleiner deleted the pulls/1203-attach-file-per-recipient-hook branch November 12, 2023 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants