From a2c77b08b7d15d9b99fc2d8ace00ca3b62bc572b Mon Sep 17 00:00:00 2001 From: Siddhant <86899184+Siddhanttimeline@users.noreply.github.com> Date: Sun, 25 Aug 2024 18:58:47 +0530 Subject: [PATCH] [FIX] EmailTemplates Edit Configurations. (#17581) * added migration for emailTemplates. * PUT will set the old template in the db.[walkaround] * remove migration. --- .../service/jdbi3/SystemRepository.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SystemRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SystemRepository.java index 00c52666309..598049453b2 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SystemRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SystemRepository.java @@ -141,6 +141,21 @@ public class SystemRepository { @Transaction public Response createOrUpdate(Settings setting) { Settings oldValue = getConfigWithKey(setting.getConfigType().toString()); + + if (oldValue != null && oldValue.getConfigType().equals(SettingsType.EMAIL_CONFIGURATION)) { + SmtpSettings configValue = + JsonUtils.convertValue(oldValue.getConfigValue(), SmtpSettings.class); + if (configValue != null) { + SmtpSettings.Templates templates = configValue.getTemplates(); + SmtpSettings newConfigValue = + JsonUtils.convertValue(setting.getConfigValue(), SmtpSettings.class); + if (newConfigValue != null) { + newConfigValue.setTemplates(templates); + setting.setConfigValue(newConfigValue); + } + } + } + try { updateSetting(setting); } catch (Exception ex) {