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

Update the theme of the email templates #202

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public static class EmailNotification {
public static final String BRANDING_PREFERENCES_IS_ENABLED_PATH = "/configs/isBrandingEnabled";
public static final String BRANDING_PREFERENCES_COPYRIGHT_TEXT_PATH = "/organizationDetails/copyrightText";
public static final String BRANDING_PREFERENCES_SUPPORT_EMAIL_PATH = "/organizationDetails/supportEmail";
public static final String BRANDING_PREFERENCES_DISPLAY_NAME_PATH = "/organizationDetails/displayName";
public static final String BRANDING_PREFERENCES_LOGO_URL_PATH = "/images/logo/imgURL";
public static final String BRANDING_PREFERENCES_LOGO_ALTTEXT_PATH = "/images/logo/altText";
public static final String BRANDING_PREFERENCES_LIGHT_THEME = "LIGHT";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.ACCOUNT_RECOVERY_ENDPOINT_PLACEHOLDER;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.AUTHENTICATION_ENDPOINT_PLACEHOLDER;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.BRANDING_PREFERENCES_COPYRIGHT_TEXT_PATH;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.BRANDING_PREFERENCES_DISPLAY_NAME_PATH;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.BRANDING_PREFERENCES_LOGO_ALTTEXT_PATH;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.BRANDING_PREFERENCES_LOGO_URL_PATH;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.BRANDING_PREFERENCES_SUPPORT_EMAIL_PATH;
Expand Down Expand Up @@ -447,6 +447,13 @@ public static String getBrandingPreference(String key, JsonNode brandingPreferen
? brandingPreferences.at(BRANDING_PREFERENCES_SUPPORT_EMAIL_PATH).asText()
: brandingFallbacks.get("support_mail");
break;
case ORGANIZATION_NAME_PLACEHOLDER :
value = (brandingIsEnabled && StringUtils.isNotBlank(
brandingPreferences.at(BRANDING_PREFERENCES_DISPLAY_NAME_PATH).asText()))
? brandingPreferences.at(BRANDING_PREFERENCES_DISPLAY_NAME_PATH).asText()
: null; // Default value is not handled here since the parameter is not passed.
// It will be handled in the caller.
break;
case "organization.color.primary" :
value = brandingIsEnabled
? !StringUtils.isBlank(getBrandingPreferenceByTheme(brandingPreferences, theme, "/colors/primary/main"))
Expand Down Expand Up @@ -551,12 +558,15 @@ public static Notification buildNotification(Event event, Map<String, String> pl
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
placeHolderData.put("current-year", String.valueOf(currentYear));

// Resolve human-readable organization name, and add it to "organization-name" placeholder.
String organizationName = resolveHumanReadableOrganizationName(tenantDomain);
placeHolderData.put(ORGANIZATION_NAME_PLACEHOLDER, organizationName);

NotificationUtil.getPlaceholderValues(emailTemplate, placeHolderData, userClaims);

if (StringUtils.isBlank(placeHolderData.get(ORGANIZATION_NAME_PLACEHOLDER))) {
// If the organization display name is not configured with branding,
// set "organization-name" placeholder to organization name.
String organizationName = resolveHumanReadableOrganizationName(tenantDomain);
placeHolderData.put(ORGANIZATION_NAME_PLACEHOLDER, organizationName);
}

Notification.EmailNotificationBuilder builder =
new Notification.EmailNotificationBuilder(sendTo);
builder.setSendFrom(sendFrom);
Expand Down
Loading
Loading