Skip to content

Commit

Permalink
PR comments and flipping a filter's logic
Browse files Browse the repository at this point in the history
  • Loading branch information
brmeyer committed Jul 16, 2023
1 parent 719c36d commit 1d43568
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,10 @@ public static class EmailList implements Serializable {
public String crmLeadFilter = "";
}

public static class ContactTagFilters implements Serializable {
public Set<String> tags = new HashSet<>();
public Set<String> tagPrefixes = new HashSet<>();
}

public static class EmailPlatform extends Platform {
public List<EmailList> lists = new ArrayList<>();
public EmailTagFilters tagFilters = new EmailTagFilters();
public ContactTagFilters contactTagFilters = new ContactTagFilters();
public Set<String> contactTagFilters = new HashSet<>();
// Transactional email (donation receipts, notifications, etc.) need one of the email platforms to be
// designated as the conduit!
public boolean transactionalSender = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,11 @@ protected void updateTags(String listId, CrmContact crmContact, List<String> crm
List<String> activeTags = getContactTagsCleaned(crmContact, crmContactCampaignNames, mailchimpConfig);
List<String> contactTags = mailchimpClient.getContactTags(listId, crmContact.email);

String[] tagPrefixesArray = mailchimpConfig.contactTagFilters.tagPrefixes.toArray(new String[]{});
String[] contactTagFilters = mailchimpConfig.contactTagFilters.toArray(new String[]{});
List<String> inactiveTags = contactTags.stream()
.filter(tag -> !activeTags.contains(tag))
.filter(tag ->
mailchimpConfig.contactTagFilters.tags.contains(tag) || StringUtils.startsWithAny(tag, tagPrefixesArray))
// filter out any tags that need to remain (IE, ones that were manually created in MC)
.filter(tag -> !StringUtils.containsAny(tag, contactTagFilters))
.collect(Collectors.toList());

mailchimpClient.updateContactTags(listId, crmContact.email, activeTags, inactiveTags);
Expand Down

0 comments on commit 1d43568

Please sign in to comment.