forked from RedHatInsights/notifications-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: allow overriding the email senders (RedHatInsights#2624)
We need to provide a way to override the email senders for different clusters than the commercial one. RHCLOUD-31979
- Loading branch information
1 parent
0b33d36
commit c73d2ef
Showing
3 changed files
with
56 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,12 @@ objects: | |
value: ${NOTIFICATIONS_EMAIL_HCC_SENDER_NAME_ENABLED} | ||
- name: NOTIFICATIONS_EMAILS_ONLY_MODE_ENABLED | ||
value: ${NOTIFICATIONS_EMAILS_ONLY_MODE_ENABLED} | ||
- name: NOTIFICATIONS_EMAIL_SENDER_HYBRID_CLOUD_CONSOLE | ||
value: ${NOTIFICATIONS_EMAIL_SENDER_HYBRID_CLOUD_CONSOLE} | ||
- name: NOTIFICATIONS_EMAIL_SENDER_OPENSHIFT_STAGE | ||
value: ${NOTIFICATIONS_EMAIL_SENDER_OPENSHIFT_STAGE} | ||
- name: NOTIFICATIONS_EMAIL_SENDER_OPENSHIFT_PROD | ||
value: ${NOTIFICATIONS_EMAIL_SENDER_OPENSHIFT_PROD} | ||
- name: NOTIFICATIONS_KAFKA_CONSUMED_TOTAL_CHECKER_ENABLED | ||
value: ${KAFKA_CONSUMED_TOTAL_CHECKER_ENABLED} | ||
- name: NOTIFICATIONS_KAFKA_CONSUMED_TOTAL_CHECKER_INITIAL_DELAY | ||
|
@@ -315,6 +321,15 @@ parameters: | |
- name: NOTIFICATIONS_EMAILS_ONLY_MODE_ENABLED | ||
description: When this is true, all integration types except emails are disabled | ||
value: "true" | ||
- name: NOTIFICATIONS_EMAIL_SENDER_HYBRID_CLOUD_CONSOLE | ||
description: The email sender address for the Red Hat Hybrid Cloud Console. | ||
value: "\"Red Hat Hybrid Cloud Console\" [email protected]" | ||
- name: NOTIFICATIONS_EMAIL_SENDER_OPENSHIFT_STAGE | ||
description: The email sender address for the OpenShift domain in stage. | ||
value: "\"Red Hat OpenShift (staging)\" [email protected]" | ||
- name: NOTIFICATIONS_EMAIL_SENDER_OPENSHIFT_PROD | ||
description: The email sender address for the OpenShift domain in production. | ||
value: "\"Red Hat OpenShift\" [email protected]" | ||
- name: NOTIFICATIONS_LOG_LEVEL | ||
description: Log level for com.redhat.cloud.notifications | ||
value: INFO | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,19 @@ | |
import io.quarkus.logging.Log; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
import java.time.LocalDate; | ||
import java.time.ZoneId; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
@ApplicationScoped | ||
public class EmailActorsResolver { | ||
@Deprecated | ||
public static final String RH_INSIGHTS_SENDER = "\"Red Hat Insights\" [email protected]"; | ||
/** | ||
* Standard "Red Hat Hybrid Cloud Console" sender that the vast majority of the | ||
* ConsoleDot applications will use. | ||
*/ | ||
public static final String RH_HCC_SENDER = "\"Red Hat Hybrid Cloud Console\" [email protected]"; | ||
@Deprecated | ||
public static final String OPENSHIFT_SENDER_STAGE = "\"Red Hat OpenShift (staging)\" [email protected]"; | ||
@Deprecated | ||
public static final String OPENSHIFT_SENDER_PROD = "\"Red Hat OpenShift\" [email protected]"; | ||
public static final String OPENSHIFT_SENDER_STAGE_NOREPLY_REDHAT = "\"Red Hat OpenShift (staging)\" [email protected]"; | ||
public static final String OPENSHIFT_SENDER_PROD_NOREPLY_REDHAT = "\"Red Hat OpenShift\" [email protected]"; | ||
private static final String STAGE_ENVIRONMENT = "stage"; | ||
public static String OCM_PENDO_MESSAGE = "The email sender address will soon be changing from [email protected] to <br/><b>[email protected]</b>.<br/><br/>If you have filtering or forwarding logic in place, you will need to update<br/>those rules by <b>%s</b>."; | ||
public static String GENERAL_PENDO_MESSAGE = "The email sender name will soon be changing from Red Hat Insights to<br/><b>Red Hat Hybrid Cloud Console</b>.<br/><br/>If you have filtering or forwarding logic in place, you will need to update<br/>those rules by <b>%s</b>."; | ||
|
@@ -30,6 +27,24 @@ public class EmailActorsResolver { | |
@ConfigProperty(name = "notifications.email.show.pendo.until.date", defaultValue = "2024-05-01") | ||
LocalDate emailChangesActivationDate; | ||
|
||
/** | ||
* The email sender address for the Red Hat Hybrid Cloud Console. | ||
*/ | ||
@ConfigProperty(name = "notifications.email.sender.hybrid.cloud.console", defaultValue = "\"Red Hat Hybrid Cloud Console\" [email protected]") | ||
protected String rhHccSender; | ||
|
||
/** | ||
* The email sender address for OpenShift in stage. | ||
*/ | ||
@ConfigProperty(name = "notifications.email.sender.openshift.stage", defaultValue = "\"Red Hat OpenShift (staging)\" [email protected]") | ||
protected String rhOpenshiftSenderStage; | ||
|
||
/** | ||
* The email sender address for OpenShift in production. | ||
*/ | ||
@ConfigProperty(name = "notifications.email.sender.openshift.prod", defaultValue = "\"Red Hat OpenShift\" [email protected]") | ||
protected String rhOpenshiftSenderProd; | ||
|
||
/** | ||
* Determines which sender should be set in the email from the given event. | ||
* When sending emails we will use the sender for both the sender itself | ||
|
@@ -55,9 +70,9 @@ public String getEmailSender(final Event event) { | |
private String getOCMEmailSender(Event event) { | ||
if (isHccEmailSenderNameEnabled()) { | ||
if (STAGE_ENVIRONMENT.equals(event.getSourceEnvironment())) { | ||
return OPENSHIFT_SENDER_STAGE_NOREPLY_REDHAT; | ||
return this.rhOpenshiftSenderStage; | ||
} else { | ||
return OPENSHIFT_SENDER_PROD_NOREPLY_REDHAT; | ||
return this.rhOpenshiftSenderProd; | ||
} | ||
} else { | ||
if (STAGE_ENVIRONMENT.equals(event.getSourceEnvironment())) { | ||
|
@@ -95,7 +110,7 @@ private boolean isOCMApp(Event event) { | |
|
||
private String getDefaultEmailSender() { | ||
if (isHccEmailSenderNameEnabled()) { | ||
return RH_HCC_SENDER; | ||
return this.rhHccSender; | ||
} else { | ||
return RH_INSIGHTS_SENDER; | ||
} | ||
|
@@ -116,4 +131,16 @@ private boolean isHccEmailSenderNameEnabled() { | |
public void setEmailChangesActivationDate(LocalDate emailChangesActivationDate) { | ||
this.emailChangesActivationDate = emailChangesActivationDate; | ||
} | ||
|
||
public String getRhHccSender() { | ||
return this.rhHccSender; | ||
} | ||
|
||
public String getOpenshiftSenderStage() { | ||
return this.rhOpenshiftSenderStage; | ||
} | ||
|
||
public String getOpenshiftSenderProd() { | ||
return this.rhOpenshiftSenderProd; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters