mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-23 08:28:10 +00:00
Fix Email Issues (#13962)
* - Added Unauthenticated Server Emails - Removed redundant OM_URI - Add Test Email in SystemResources * remove default port * remove fernet
This commit is contained in:
parent
e367f557a6
commit
2ae0333551
@ -299,7 +299,7 @@ email:
|
||||
emailingEntity: ${OM_EMAIL_ENTITY:-"OpenMetadata"}
|
||||
supportUrl: ${OM_SUPPORT_URL:-"https://slack.open-metadata.org"}
|
||||
enableSmtpServer : ${AUTHORIZER_ENABLE_SMTP:-false}
|
||||
openMetadataUrl: ${OPENMETADATA_SERVER_URL:-""}
|
||||
openMetadataUrl: ${OPENMETADATA_SERVER_URL:-"http://localhost:8585"}
|
||||
senderMail: ${OPENMETADATA_SMTP_SENDER_MAIL:-""}
|
||||
serverEndpoint: ${SMTP_SERVER_ENDPOINT:-""}
|
||||
serverPort: ${SMTP_SERVER_PORT:-""}
|
||||
@ -335,7 +335,3 @@ web:
|
||||
enabled: ${WEB_CONF_PERMISSION_POLICY_ENABLED:-false}
|
||||
option: ${WEB_CONF_PERMISSION_POLICY_OPTION:-""}
|
||||
|
||||
|
||||
changeEventConfig:
|
||||
omUri: ${OM_URI:- "http://localhost:8585"} #openmetadata in om uri for eg http://localhost:8585
|
||||
|
||||
|
@ -166,9 +166,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
#extensionConfiguration
|
||||
OM_RESOURCE_PACKAGES: ${OM_RESOURCE_PACKAGES:-[]}
|
||||
OM_EXTENSIONS: ${OM_EXTENSIONS:-[]}
|
||||
@ -314,9 +311,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
#extensionConfiguration
|
||||
OM_RESOURCE_PACKAGES: ${OM_RESOURCE_PACKAGES:-[]}
|
||||
OM_EXTENSIONS: ${OM_EXTENSIONS:-[]}
|
||||
|
@ -165,9 +165,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
#extensionConfiguration
|
||||
OM_RESOURCE_PACKAGES: ${OM_RESOURCE_PACKAGES:-[]}
|
||||
OM_EXTENSIONS: ${OM_EXTENSIONS:-[]}
|
||||
@ -315,9 +312,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
#extensionConfiguration
|
||||
OM_RESOURCE_PACKAGES: ${OM_RESOURCE_PACKAGES:-[]}
|
||||
OM_EXTENSIONS: ${OM_EXTENSIONS:-[]}
|
||||
|
@ -115,9 +115,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
#extensionConfiguration
|
||||
OM_RESOURCE_PACKAGES: ${OM_RESOURCE_PACKAGES:-[]}
|
||||
OM_EXTENSIONS: ${OM_EXTENSIONS:-[]}
|
||||
@ -259,9 +256,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
#extensionConfiguration
|
||||
OM_RESOURCE_PACKAGES: ${OM_RESOURCE_PACKAGES:-[]}
|
||||
OM_EXTENSIONS: ${OM_EXTENSIONS:-[]}
|
||||
|
@ -82,15 +82,13 @@ OM_SM_ACCESS_KEY=""
|
||||
OM_EMAIL_ENTITY="OpenMetadata"
|
||||
OM_SUPPORT_URL="https://slack.open-metadata.org"
|
||||
AUTHORIZER_ENABLE_SMTP="false"
|
||||
OPENMETADATA_SERVER_URL=""
|
||||
OPENMETADATA_SERVER_URL="http://localhost:8585"
|
||||
OPENMETADATA_SMTP_SENDER_MAIL=""
|
||||
SMTP_SERVER_ENDPOINT=""
|
||||
SMTP_SERVER_PORT=""
|
||||
SMTP_SERVER_USERNAME=""
|
||||
SMTP_SERVER_PWD=""
|
||||
SMTP_SERVER_STRATEGY="SMTP_TLS"
|
||||
#changeEventConfig
|
||||
OM_URI= "http://localhost:8585"
|
||||
#extensionConfiguration
|
||||
OM_RESOURCE_PACKAGES="[]"
|
||||
OM_EXTENSIONS="[]"
|
||||
|
@ -82,15 +82,13 @@ OM_SM_ACCESS_KEY=""
|
||||
OM_EMAIL_ENTITY="OpenMetadata"
|
||||
OM_SUPPORT_URL="https://slack.open-metadata.org"
|
||||
AUTHORIZER_ENABLE_SMTP="false"
|
||||
OPENMETADATA_SERVER_URL=""
|
||||
OPENMETADATA_SERVER_URL="http://localhost:8585"
|
||||
OPENMETADATA_SMTP_SENDER_MAIL=""
|
||||
SMTP_SERVER_ENDPOINT=""
|
||||
SMTP_SERVER_PORT=""
|
||||
SMTP_SERVER_USERNAME=""
|
||||
SMTP_SERVER_PWD=""
|
||||
SMTP_SERVER_STRATEGY="SMTP_TLS"
|
||||
#changeEventConfig
|
||||
OM_URI= "http://localhost:8585"
|
||||
#extensionConfiguration
|
||||
OM_RESOURCE_PACKAGES="[]"
|
||||
OM_EXTENSIONS="[]"
|
||||
|
@ -159,9 +159,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
# Heap OPTS Configurations
|
||||
OPENMETADATA_HEAP_OPTS: ${OPENMETADATA_HEAP_OPTS:--Xmx1G -Xms1G}
|
||||
# Mask passwords values in UI
|
||||
@ -304,9 +301,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
# Heap OPTS Configurations
|
||||
OPENMETADATA_HEAP_OPTS: ${OPENMETADATA_HEAP_OPTS:--Xmx1G -Xms1G}
|
||||
# Mask passwords values in UI
|
||||
|
@ -157,9 +157,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
# Heap OPTS Configurations
|
||||
OPENMETADATA_HEAP_OPTS: ${OPENMETADATA_HEAP_OPTS:--Xmx1G -Xms1G}
|
||||
# Mask passwords values in UI
|
||||
@ -302,9 +299,6 @@ services:
|
||||
SMTP_SERVER_PWD: ${SMTP_SERVER_PWD:-""}
|
||||
SMTP_SERVER_STRATEGY: ${SMTP_SERVER_STRATEGY:-"SMTP_TLS"}
|
||||
|
||||
#changeEventConfig
|
||||
OM_URI: ${OM_URI:- "http://localhost:8585"}
|
||||
|
||||
# Heap OPTS Configurations
|
||||
OPENMETADATA_HEAP_OPTS: ${OPENMETADATA_HEAP_OPTS:--Xmx1G -Xms1G}
|
||||
# Mask passwords values in UI
|
||||
|
@ -1,23 +0,0 @@
|
||||
package org.openmetadata.service;
|
||||
|
||||
import org.openmetadata.api.configuration.ChangeEventConfiguration;
|
||||
|
||||
public class ChangeEventConfig {
|
||||
private static ChangeEventConfiguration instance;
|
||||
private static volatile boolean initialized = false;
|
||||
|
||||
private ChangeEventConfig() {
|
||||
/* Hide constructor for singleton */
|
||||
}
|
||||
|
||||
public static void initialize(OpenMetadataApplicationConfig config) {
|
||||
if (!initialized) {
|
||||
instance = config.getChangeEventConfiguration();
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static ChangeEventConfiguration getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
@ -132,7 +132,6 @@ public class OpenMetadataApplication extends Application<OpenMetadataApplication
|
||||
// init for dataSourceFactory
|
||||
DatasourceConfig.initialize(catalogConfig.getDataSourceFactory().getDriverClass());
|
||||
|
||||
ChangeEventConfig.initialize(catalogConfig);
|
||||
final Jdbi jdbi = createAndSetupJDBI(environment, catalogConfig.getDataSourceFactory());
|
||||
CollectionDAO collectionDAO = jdbi.onDemand(CollectionDAO.class);
|
||||
Entity.setCollectionDAO(collectionDAO);
|
||||
|
@ -22,7 +22,6 @@ import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.openmetadata.api.configuration.ChangeEventConfiguration;
|
||||
import org.openmetadata.schema.api.configuration.events.EventHandlerConfiguration;
|
||||
import org.openmetadata.schema.api.configuration.pipelineServiceClient.PipelineServiceClientConfiguration;
|
||||
import org.openmetadata.schema.api.fernet.FernetConfiguration;
|
||||
@ -94,9 +93,6 @@ public class OpenMetadataApplicationConfig extends Configuration {
|
||||
@JsonProperty("web")
|
||||
private OMWebConfiguration webConfiguration = new OMWebConfiguration();
|
||||
|
||||
@JsonProperty("changeEventConfig")
|
||||
private ChangeEventConfiguration changeEventConfiguration;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "catalogConfig{"
|
||||
|
@ -15,12 +15,12 @@ package org.openmetadata.service.formatter.decorators;
|
||||
|
||||
import static org.openmetadata.service.events.subscription.AlertsRuleEvaluator.getEntity;
|
||||
import static org.openmetadata.service.formatter.util.FormatterUtil.getFormattedMessages;
|
||||
import static org.openmetadata.service.util.EmailUtil.getSmtpSettings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.openmetadata.schema.type.ChangeEvent;
|
||||
import org.openmetadata.service.ChangeEventConfig;
|
||||
import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.events.subscription.email.EmailMessage;
|
||||
import org.openmetadata.service.resources.feeds.MessageParser;
|
||||
@ -59,7 +59,7 @@ public class EmailMessageDecorator implements MessageDecorator<EmailMessage> {
|
||||
@Override
|
||||
public String getEntityUrl(String entityType, String fqn) {
|
||||
return String.format(
|
||||
"<a href = '%s/%s/%s'>%s</a>", ChangeEventConfig.getInstance().getOmUri(), entityType, fqn.trim(), fqn.trim());
|
||||
"<a href = '%s/%s/%s'>%s</a>", getSmtpSettings().getOpenMetadataUrl(), entityType, fqn.trim(), fqn.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,12 +15,12 @@ package org.openmetadata.service.formatter.decorators;
|
||||
|
||||
import static org.openmetadata.service.events.subscription.AlertsRuleEvaluator.getEntity;
|
||||
import static org.openmetadata.service.formatter.util.FormatterUtil.getFormattedMessages;
|
||||
import static org.openmetadata.service.util.EmailUtil.getSmtpSettings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.openmetadata.schema.type.ChangeEvent;
|
||||
import org.openmetadata.service.ChangeEventConfig;
|
||||
import org.openmetadata.service.events.subscription.gchat.GChatMessage;
|
||||
import org.openmetadata.service.resources.feeds.MessageParser;
|
||||
|
||||
@ -60,7 +60,7 @@ public class GChatMessageDecorator implements MessageDecorator<GChatMessage> {
|
||||
public String getEntityUrl(String entityType, String fqn) {
|
||||
return String.format(
|
||||
"<%s/%s/%s|%s>",
|
||||
ChangeEventConfig.getInstance().getOmUri(), entityType, fqn.trim().replace(" ", "%20"), fqn.trim());
|
||||
getSmtpSettings().getOpenMetadataUrl(), entityType, fqn.trim().replace(" ", "%20"), fqn.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,12 +15,12 @@ package org.openmetadata.service.formatter.decorators;
|
||||
|
||||
import static org.openmetadata.service.events.subscription.AlertsRuleEvaluator.getEntity;
|
||||
import static org.openmetadata.service.formatter.util.FormatterUtil.getFormattedMessages;
|
||||
import static org.openmetadata.service.util.EmailUtil.getSmtpSettings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.openmetadata.schema.type.ChangeEvent;
|
||||
import org.openmetadata.service.ChangeEventConfig;
|
||||
import org.openmetadata.service.events.subscription.msteams.TeamsMessage;
|
||||
import org.openmetadata.service.resources.feeds.MessageParser;
|
||||
|
||||
@ -58,7 +58,7 @@ public class MSTeamsMessageDecorator implements MessageDecorator<TeamsMessage> {
|
||||
|
||||
@Override
|
||||
public String getEntityUrl(String entityType, String fqn) {
|
||||
return String.format("[%s](/%s/%s)", fqn.trim(), ChangeEventConfig.getInstance().getOmUri(), entityType);
|
||||
return String.format("[%s](/%s/%s)", fqn.trim(), getSmtpSettings().getOpenMetadataUrl(), entityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,13 +15,13 @@ package org.openmetadata.service.formatter.decorators;
|
||||
|
||||
import static org.openmetadata.service.events.subscription.AlertsRuleEvaluator.getEntity;
|
||||
import static org.openmetadata.service.formatter.util.FormatterUtil.getFormattedMessages;
|
||||
import static org.openmetadata.service.util.EmailUtil.getSmtpSettings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.openmetadata.schema.tests.TestCase;
|
||||
import org.openmetadata.schema.type.ChangeEvent;
|
||||
import org.openmetadata.service.ChangeEventConfig;
|
||||
import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.events.subscription.slack.SlackAttachment;
|
||||
import org.openmetadata.service.events.subscription.slack.SlackMessage;
|
||||
@ -62,7 +62,7 @@ public class SlackMessageDecorator implements MessageDecorator<SlackMessage> {
|
||||
public String getEntityUrl(String entityType, String fqn) {
|
||||
return String.format(
|
||||
"<%s/%s/%s|%s>",
|
||||
ChangeEventConfig.getInstance().getOmUri(), entityType, fqn.trim().replaceAll(" ", "%20"), fqn.trim());
|
||||
getSmtpSettings().getOpenMetadataUrl(), entityType, fqn.trim().replaceAll(" ", "%20"), fqn.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.openmetadata.service.resources.system;
|
||||
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -10,6 +11,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.io.IOException;
|
||||
import javax.json.JsonPatch;
|
||||
import javax.validation.Valid;
|
||||
import javax.ws.rs.Consumes;
|
||||
@ -38,6 +40,7 @@ import org.openmetadata.service.jdbi3.ListFilter;
|
||||
import org.openmetadata.service.jdbi3.SystemRepository;
|
||||
import org.openmetadata.service.resources.Collection;
|
||||
import org.openmetadata.service.security.Authorizer;
|
||||
import org.openmetadata.service.util.EmailUtil;
|
||||
import org.openmetadata.service.util.ResultList;
|
||||
|
||||
@Path("/v1/system")
|
||||
@ -123,6 +126,25 @@ public class SystemResource {
|
||||
return systemRepository.createOrUpdate(settingName);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/email/test")
|
||||
@Operation(
|
||||
operationId = "sendTestEmail",
|
||||
summary = "Sends a Test Email",
|
||||
description = "Sends a Test Email with Provided Settings",
|
||||
responses = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "EmailTest",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)))
|
||||
})
|
||||
public Response sendTestEmail(@Context UriInfo uriInfo, @Context SecurityContext securityContext, String email)
|
||||
throws TemplateException, IOException {
|
||||
authorizer.authorizeAdmin(securityContext);
|
||||
EmailUtil.sendTestEmail(email);
|
||||
return Response.status(Response.Status.OK).entity("Test Email Sent Successfully.").build();
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("/settings/{settingName}")
|
||||
@Operation(
|
||||
|
@ -29,6 +29,7 @@ import static org.openmetadata.service.exception.CatalogExceptionMessage.MAX_FAI
|
||||
import static org.openmetadata.service.exception.CatalogExceptionMessage.SELF_SIGNUP_ERROR;
|
||||
import static org.openmetadata.service.exception.CatalogExceptionMessage.TOKEN_EXPIRY_ERROR;
|
||||
import static org.openmetadata.service.resources.teams.UserResource.USER_PROTECTED_FIELDS;
|
||||
import static org.openmetadata.service.util.EmailUtil.getSmtpSettings;
|
||||
|
||||
import at.favre.lib.crypto.bcrypt.BCrypt;
|
||||
import freemarker.template.TemplateException;
|
||||
@ -166,7 +167,7 @@ public class BasicAuthenticator implements AuthenticatorHandler {
|
||||
String emailVerificationLink =
|
||||
String.format(
|
||||
"%s/users/registrationConfirmation?user=%s&token=%s",
|
||||
EmailUtil.buildBaseUrl(uriInfo.getRequestUri()), user.getFullyQualifiedName(), mailVerificationToken);
|
||||
getSmtpSettings().getOpenMetadataUrl(), user.getFullyQualifiedName(), mailVerificationToken);
|
||||
try {
|
||||
EmailUtil.sendEmailVerification(emailVerificationLink, user);
|
||||
} catch (TemplateException e) {
|
||||
@ -187,7 +188,7 @@ public class BasicAuthenticator implements AuthenticatorHandler {
|
||||
String passwordResetLink =
|
||||
String.format(
|
||||
"%s/users/password/reset?user=%s&token=%s",
|
||||
EmailUtil.buildBaseUrl(uriInfo.getRequestUri()), user.getFullyQualifiedName(), mailVerificationToken);
|
||||
getSmtpSettings().getOpenMetadataUrl(), user.getFullyQualifiedName(), mailVerificationToken);
|
||||
try {
|
||||
EmailUtil.sendPasswordResetLink(passwordResetLink, user, subject, templateFilePath);
|
||||
} catch (TemplateException e) {
|
||||
|
@ -23,7 +23,6 @@ import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@ -78,9 +77,10 @@ public class EmailUtil {
|
||||
public static final String CHANGE_EVENT_TEMPLATE = "changeEvent.ftl";
|
||||
public static final String INVITE_CREATE_PWD = "invite-createPassword.ftl";
|
||||
public static final String TASK_NOTIFICATION_TEMPLATE = "taskAssignment.ftl";
|
||||
|
||||
private static final String REPORT_SUBJECT = "%s: Data Insights Weekly - %s";
|
||||
public static final String DATA_INSIGHT_REPORT_TEMPLATE = "dataInsightReport.ftl";
|
||||
public static final String TEST_EMAIL_TEMPLATE = "testMail.ftl";
|
||||
public static final String TEST_EMAIL_SUBJECT = "%s : Test Email";
|
||||
private static SmtpSettings storedSmtpSettings;
|
||||
private static Mailer mailer;
|
||||
private static final Configuration templateConfiguration = new Configuration(VERSION_2_3_28);
|
||||
@ -110,11 +110,12 @@ public class EmailUtil {
|
||||
strategy = SMTP;
|
||||
break;
|
||||
}
|
||||
String username =
|
||||
CommonUtil.nullOrEmpty(smtpServerSettings.getUsername()) ? null : smtpServerSettings.getUsername();
|
||||
String password =
|
||||
CommonUtil.nullOrEmpty(smtpServerSettings.getPassword()) ? null : smtpServerSettings.getPassword();
|
||||
return MailerBuilder.withSMTPServer(
|
||||
smtpServerSettings.getServerEndpoint(),
|
||||
smtpServerSettings.getServerPort(),
|
||||
smtpServerSettings.getUsername(),
|
||||
smtpServerSettings.getPassword())
|
||||
smtpServerSettings.getServerEndpoint(), smtpServerSettings.getServerPort(), username, password)
|
||||
.withTransportStrategy(strategy)
|
||||
.buildMailer();
|
||||
}
|
||||
@ -246,19 +247,6 @@ public class EmailUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static String buildBaseUrl(URI uri) {
|
||||
try {
|
||||
if (CommonUtil.nullOrEmpty(getSmtpSettings().getOpenMetadataUrl())) {
|
||||
return String.format("%s://%s", uri.getScheme(), uri.getHost());
|
||||
} else {
|
||||
URI serverUrl = new URI(getSmtpSettings().getOpenMetadataUrl());
|
||||
return String.format("%s://%s", serverUrl.getScheme(), serverUrl.getHost());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalArgumentException("Missing URI info from URI and SMTP settings.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendInviteMailToAdmin(User user, String pwd) {
|
||||
if (Boolean.TRUE.equals(getSmtpSettings().getEnableSmtpServer())) {
|
||||
Map<String, Object> templatePopulator = new HashMap<>();
|
||||
@ -330,6 +318,18 @@ public class EmailUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendTestEmail(String email) throws IOException, TemplateException {
|
||||
if (Boolean.TRUE.equals(getSmtpSettings().getEnableSmtpServer())) {
|
||||
Map<String, Object> templatePopulator = new HashMap<>();
|
||||
templatePopulator.put("userName", email.split("@")[0]);
|
||||
templatePopulator.put("entity", getSmtpSettings().getEmailingEntity());
|
||||
templatePopulator.put("supportUrl", getSmtpSettings().getSupportUrl());
|
||||
sendMail(getTestEmailSubject(), templatePopulator, email, EMAIL_TEMPLATE_BASEPATH, TEST_EMAIL_TEMPLATE);
|
||||
} else {
|
||||
LOG.warn(EMAIL_IGNORE_MSG, email);
|
||||
}
|
||||
}
|
||||
|
||||
public static void testConnection() {
|
||||
mailer.testConnection();
|
||||
}
|
||||
@ -358,6 +358,10 @@ public class EmailUtil {
|
||||
return String.format(TASK_SUBJECT, getSmtpSettings().getEmailingEntity());
|
||||
}
|
||||
|
||||
public static String getTestEmailSubject() {
|
||||
return String.format(TEST_EMAIL_SUBJECT, getSmtpSettings().getEmailingEntity());
|
||||
}
|
||||
|
||||
public static String getDataInsightReportSubject() {
|
||||
return String.format(
|
||||
REPORT_SUBJECT, getSmtpSettings().getEmailingEntity(), new SimpleDateFormat("dd-MM-yy").format(new Date()));
|
||||
@ -375,7 +379,7 @@ public class EmailUtil {
|
||||
return getSmtpSettings().getOpenMetadataUrl();
|
||||
}
|
||||
|
||||
private static SmtpSettings getSmtpSettings() {
|
||||
public static SmtpSettings getSmtpSettings() {
|
||||
SmtpSettings emailConfig = SettingsCache.getSetting(SettingsType.EMAIL_CONFIGURATION, SmtpSettings.class);
|
||||
if (!emailConfig.equals(storedSmtpSettings)) {
|
||||
storedSmtpSettings = emailConfig;
|
||||
|
@ -15,6 +15,7 @@ package org.openmetadata.service.util;
|
||||
|
||||
import static org.openmetadata.service.Entity.TEAM;
|
||||
import static org.openmetadata.service.Entity.USER;
|
||||
import static org.openmetadata.service.util.EmailUtil.getSmtpSettings;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@ -162,7 +163,7 @@ public class NotificationHandler {
|
||||
EmailUtil.sendTaskAssignmentNotificationToUser(
|
||||
user.getName(),
|
||||
user.getEmail(),
|
||||
String.format("%s/users/%s/tasks", EmailUtil.buildBaseUrl(urlInstance), user.getName()),
|
||||
String.format("%s/users/%s/tasks", getSmtpSettings().getOpenMetadataUrl(), user.getName()),
|
||||
thread,
|
||||
EmailUtil.getTaskAssignmentSubject(),
|
||||
EmailUtil.TASK_NOTIFICATION_TEMPLATE);
|
||||
|
@ -126,11 +126,6 @@ public class PaginatedEntitiesSource implements Source<ResultList<? extends Enti
|
||||
getUpdatedStats(stats, currentSuccess, currentFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepStats getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
public String getLastFailedCursor() {
|
||||
return lastFailedCursor;
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
<!-- [if !mso]>
|
||||
<!-->
|
||||
<!--![endif]-->
|
||||
<!-- Normalize Styles -->
|
||||
<!-- [if gte mso 9]>
|
||||
<style type="text/css">
|
||||
/* What it does: Normalize space between bullets and text. */
|
||||
/* https://litmus.com/community/discussions/1093-bulletproof-lists-using-ul-and-li */
|
||||
li {
|
||||
text-indent: -1em;
|
||||
}
|
||||
</style>
|
||||
<![endif]-->
|
||||
<div style="display: none; font-size: 1px; line-height: 1px; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; font-family: sans-serif;"> </div>
|
||||
<table style="background: #F7F8FA; border: 0; border-radius: 0; width: 100%;" cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tw-body" style="padding: 15px 15px 0;" align="center">
|
||||
<table style="background: #F7F8FA; border: 0; border-radius: 0;" cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="" style="width: 600px;" align="center">
|
||||
<p style="padding: 5px 5px 5px; font-size: 13px; margin: 0 0 0px; color: #316fea;" align="right"></p>
|
||||
<table style="background: #ffffff; border: 0px; border-radius: 4px; width: 99.6672%; overflow: hidden;" cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="" style="padding: 0px; width: 100%;" align="center">
|
||||
<table style="background: #336f85; border: 0px; border-radius: 0px; width: 599px; height: 53px; margin-left: auto; margin-right: auto;" cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tw-card-header" style="padding: 5px 5px px; width: 366px; color: #ffff; text-decoration: none; font-family: sans-serif;" align="center">
|
||||
<span style="font-weight: 600;">Email Test</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
<br />
|
||||
<br />
|
||||
</p>
|
||||
<table dir="ltr" style="border: 0; width: 100%;" cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tw-card-body" style="padding: 20px 35px; text-align: left; color: #6f6f6f; font-family: sans-serif; border-top: 0;">
|
||||
<h1 class="tw-h1" style="font-size: 24px; font-weight: bold; mso-line-height-rule: exactly; line-height: 32px; margin: 0 0 20px; color: #474747;"> Hi ${userName},</h1>
|
||||
<br />
|
||||
<span style="font-weight: 400;">This is a Test Email, receiving this Email Confirms that you have successfully configured OpenMetadata to send Mails.</span>
|
||||
<p class="" style="margin: 20px 0; font-size: 16px; mso-line-height-rule: exactly; line-height: 24px;"> Feel free to reachout to us on <a style="color: #316fea; text-decoration: none;" href="${supportUrl}" target="_blank" rel="noopener">Slack</a> for any questions you may have. </p>
|
||||
<p class="tw-signoff" style="margin: 45px 0 5px; font-size: 16px; mso-line-height-rule: exactly; line-height: 24px;"> Thanks, <br />The ${entity} Team </p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
@ -216,7 +216,7 @@ email:
|
||||
enableSmtpServer : false
|
||||
emailingEntity: ""
|
||||
supportUrl: ""
|
||||
openMetadataUrl: ""
|
||||
openMetadataUrl: "http://localhost:8585"
|
||||
senderMail: ""
|
||||
serverEndpoint: ""
|
||||
serverPort: ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user