Skip to content

Commit

Permalink
zcs
Browse files Browse the repository at this point in the history
  • Loading branch information
rendurama committed Jul 5, 2024
1 parent 30b9f7a commit aafda60
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion store/conf/attrs/zimbra-attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10474,7 +10474,7 @@ TODO: delete them permanently from here
<desc>Define body: field for 2FA email in html format</desc>
</attr>

<attr id="4116" name="zimbraHideAliasesInGal" type="boolean" cardinality="single" optionalIn="account" flags="accountInfo" since="10.1.0">
<attr id="4116" name="zimbraHideAliasesInGal" type="boolean" cardinality="single" optionalIn="account,cos,domain" flags="accountInfo" since="10.1.0">
<desc>When set to True, all aliases will be hidden for particular account</desc>
</attr>

Expand Down
13 changes: 6 additions & 7 deletions store/src/java/com/zimbra/cs/account/ldap/LdapProvisioning.java
Original file line number Diff line number Diff line change
Expand Up @@ -11729,14 +11729,13 @@ public String sendMdmEmail(String status, String timeInterval) throws ServiceExc


@Override
public void excludePrivateAliases(NamedEntry entry, List<String> aliases) throws ServiceException {
public void excludePrivateAliases(NamedEntry entry, List<String> emailAndAliases) throws ServiceException {

LdapUsage ldapUsage = LdapUsage.GAL_SEARCH;

ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, ldapUsage);

for (String alias : new ArrayList<>(aliases)) {

for (String alias : new ArrayList<>( emailAndAliases.subList( 1, emailAndAliases.size()))) { // exclude primay email here
if (null != alias) {
String parts[] = alias.split("@");
String aliasName = parts[0];
Expand All @@ -11752,15 +11751,15 @@ public void excludePrivateAliases(NamedEntry entry, List<String> aliases) throws

Alias aliasEntryLocal = makeAlias(aliasDn, attrs);

NamedEntry targetEntry = searchAliasTarget(aliasEntryLocal, false);
//NamedEntry targetEntry = searchAliasTarget(aliasEntryLocal, false);

boolean isSame = (entry.getId().equals(targetEntry.getId()));
// boolean isSame = (entry.getId().equals(targetEntry.getId()));

if ("TRUE".equalsIgnoreCase(aliasEntryLocal.getAttr(Provisioning.A_zimbraHideAliasInGal))) {
aliases.remove(alias);
emailAndAliases.remove(alias);
}
ZimbraLog.mailbox.info("alias attribute for %s is %s and isSame %s ", alias,
aliasEntryLocal.getAttr(Provisioning.A_zimbraHideAliasInGal), isSame);
aliasEntryLocal.getAttr(Provisioning.A_zimbraHideAliasInGal), true);
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions store/src/java/com/zimbra/cs/mailbox/ContactAutoComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -710,23 +710,26 @@ public void addMatchedContacts(String query, Map<String, ? extends Object> attrs
displayName = Joiner.on(' ').skipNulls().join(first, middle, last);
}

List<String> allowedEmailsList = new ArrayList<>();
List<String> allowedEmailsListInGalAutocomplete = new ArrayList<>();
for(String emailKey: mEmailKeys) {
if (!emailKey.equals(Constants.PRIMARY_EMAIL)) {
//check if all aliases of an account need to be bypassed
if (account.isHideAliasesInGal()) {
break;
}
}
allowedEmailsList.add(getFieldAsString(attrs, emailKey));
String email = getFieldAsString(attrs, emailKey);
if(null != email) {
allowedEmailsListInGalAutocomplete.add(email);
}
}
ZimbraLog.mailbox.info("allowed list 1 is %s", allowedEmailsList);
ZimbraLog.mailbox.info("allowed list 1 is %s", allowedEmailsListInGalAutocomplete);

Provisioning.getInstance().excludePrivateAliases(account, allowedEmailsList.subList( 1, allowedEmailsList.size()));
Provisioning.getInstance().excludePrivateAliases(account, allowedEmailsListInGalAutocomplete);

ZimbraLog.mailbox.info("allowed list 2 is %s", allowedEmailsList);
ZimbraLog.mailbox.info("allowed list 2 is %s", allowedEmailsListInGalAutocomplete);

for (String email : allowedEmailsList) {
for (String email : allowedEmailsListInGalAutocomplete) {
if (email != null && (nameMatches || matchesEmail(tokens, email))) {
ContactEntry entry = new ContactEntry();
entry.mEmail = email;
Expand Down

0 comments on commit aafda60

Please sign in to comment.