forked from civicrm/civicrm-core
-
Notifications
You must be signed in to change notification settings - Fork 4
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
CATL-1613: Add options to Mail Account settings to improve inbound mail processing #42
Open
i-grou
wants to merge
1,197
commits into
master
Choose a base branch
from
CATL-1613-skip-non-case-email
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i-grou
force-pushed
the
CATL-1613-skip-non-case-email
branch
8 times, most recently
from
August 20, 2020 11:43
de3440b
to
5f754b5
Compare
i-grou
force-pushed
the
CATL-1613-skip-non-case-email
branch
2 times, most recently
from
September 10, 2020 08:59
e8f78a0
to
248c73d
Compare
There is only 1 remaining place that calls this function & does not specifiy activityType. This fixes that place to pass in activityType and stops attempting to calculate activityType based on in-function guess work
[REF] Update composer compile plugin to latest version
[REF] Finally remove deprecated ids handling
[REF] Move daoName generation so we don't need to pass the variable name
…Entity function This seems more legible than the metadata trick....
Minor test fix
dev/core#2017 Remove unused function OpenID::isAllowedToLogin
Minor test data fix up - ensure domain contact's email is primary
dev/core#2030 ensure that the Country selector is a Select 2 and ensu…
Maybe this will help us understand why the test is intermittant
dev/core#2040 - Multiple email activity cc recipients get scrunched together in recorded activity details field
[REF] Remove unreachable lines
dev/core#2029 Extend test debug
[REF] Remove wrangling on activityType param
Switch membership BAO to use non-deprecated cached functions to get membershipType details
dev/core#2079 do not return never-used, query-wasting variable
dev/core#2079 [REF] clean up call to apiQuery
i-grou
force-pushed
the
CATL-1613-skip-non-case-email
branch
3 times, most recently
from
October 6, 2020 10:02
2b3c03d
to
fbb997c
Compare
dev/core#2093 - Fix red error box on new individual form and ltrim typos and doubling-up of class attribute
change civicrm_price_set.min_amount to float
dev/core#2079 [REF] clean up call to apiQuery
dev/core#2046 Fix blockDelete to delete while ensuring is_primary is valid
dev/core#2046 Migrate BAO_Address::create towards standardisation
…bility [REF] Fix compatability with Drupal 9 installing of var_dumper
blockDelete is now just wrapper for del so this is really NFC
Search ext: rename to Search Kit, mark as beta
dev/core#2039 Call del directly - rather than now-deprecated blockDelete
…s a required field
dev/core#1790 - Contact Card - Email Links
[REF] Fix error when creating new AB test mailing because domain_id i…
[NFC] Update Checksum on CustomField DAO
i-grou
force-pushed
the
CATL-1613-skip-non-case-email
branch
2 times, most recently
from
October 7, 2020 07:50
fbb997c
to
234faf6
Compare
… contacts when filing emails
… do not have a Case ID or Case token
i-grou
force-pushed
the
CATL-1613-skip-non-case-email
branch
from
October 7, 2020 07:55
234faf6
to
f945f0c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
According to new requirements we need to add an additional options to the Mail Account settings (see Mail Accounts page
/civicrm/admin/mailSettings?action=add&reset=1
) to change the email to activity processing behavior - whenEmail-to-Activity Processing
value is selected for Used For? field we need to:If checked: emails which do not have a valid case ID or case token should be moved into the
ignored
mail folder after processing and no activity should be created.If checked: when CiviCRM checks for a matching contact, if no matching contact is found it will not create one and the email is filed.
So now administrator should be able to configure whether CiviCRM will create a new contact where a contact does not already exist within the system when filing inbound emails, so that he can ensure that new contacts are not created in the system when filing an email. The email should still be filed, even if no contacts are matched.
Email is considered to be related to cases if it's subject matches any of the following conditions:
[<any string> #<any string>]
, e.g:[case #2cd8467]
,[policy initiative #bdf3896]
.Case ID <number>
, e.g:Case ID 1298
,case id 9
.Also:
Before
Without the new options above enabled CiviCRM will process emails as normal i.e:
And Activity Status field label location is not changed.
After
With the new options above enabled CiviCRM:
ignored
folder.Now form looks like this:
Technical Details
To make the Skip emails which do not have a Case ID or Case token checkbox work we:
civicrm_mail_settings
db table -is_non_case_email_skipped
. Respective upgrader is added.MailSettings.xml
file to have new field.Form/MailSettings.php
andMailSettings.tpl
- to print new field and save the value on form submit. As it has long help text it was desided to move it toMailSettings.hlp
file and use civicrm ajax help popup feature.EmailProcessor.php
to handle new field during inbound email processing.CRM_Utils_Mail_CaseMail
class is added to storeisCaseEmail()
method, which is used to check if email is related to cases or not before email processing (creating new activity). The regexp patterns are copied fromCRM_Activity_BAO_Activity->create()
method for consistency, as it also performs this check.caseEmailSubjectPatterns()
hook is added to make it possible to change default email subject regexp patterns. It may be useful for example for CiviCase extension to add case type category names to patterns.is_non_case_email_skipped
enabled) of 2 emails: with case hash in subject and without case hash.MailSettings.tpl
file is fixed._civicrm_api3_deprecated_activity_buildmailparams()
method was moved toCRM_Utils_Mail_ParamsBuilder
class that was just created and now we can useCRM_Utils_Mail_ParamsBuilder->buildActivityParams()
instead. This was done to get rid of some toxic code.To make the Do not create new contacts when filing emails checkobx work we:
civicrm_mail_settings
db table -is_contact_creation_disabled_if_no_match
. Respective upgrader is added.DAO/MailSettings.php
and schemaMailSettings.xml
files to have new field.Form/MailSettings.php
andMailSettings.tpl
- to print new field and save the value on form submit.EmailProcessor.php
to handle new field during inbound email processing. This also involved updating theIncoming.php
to make contact creation optional.is_contact_creation_disabled_if_no_match
enabled.About the new
CRM_Utils_Mail_CaseMail
classThis class has a potential to become generic and widely used class, thats why:
• Email subject patterns are not just hardcoded, but are reusable, see
getSubjectPatterns()
method.• The
getSubjectPatterns()
method is written keeping in mindCiviCase
extension (thats whycaseEmailSubjectPatterns()
hook is added), which has case type categories, which names could be used in email subject, e.g:[case #hahoheh] Super email
->[policy initiative #hahoheh] Super email
.For now the most useful part of this class is
isCaseEmail()
method, but some other methods may be added later. For example:$hash = substr(sha1(CIVICRM_SITE_KEY . $form->_caseId), 0, 7)
.$subject = "[case #$hash] $subject"
.⚠ The email regexp patterns are copied from
CRM_Activity_BAO_Activity->create()
and now it makes sense to refactor that method to useCRM_Utils_Mail_CaseMail->getSubjectPatterns()
to get patterns. But will skip it now as it's not in the scope of the task.One more comment
I've noticed that civicrm stops processing of inbound email if it failed to connect to some mail account. This may cause some issues in case if there are several accounts created: if processing would be stopped on first account - then no other accounts would be processed as well.
I guess this should be added to the todo list to fix in the nearest future.