diff --git a/.rhcicd/clowdapp-engine.yaml b/.rhcicd/clowdapp-engine.yaml
index 7459af91c5..003a7d6934 100644
--- a/.rhcicd/clowdapp-engine.yaml
+++ b/.rhcicd/clowdapp-engine.yaml
@@ -151,8 +151,6 @@ objects:
key: client-id
- name: PROCESSOR_EMAIL_BOP_ENV
value: ${BACKOFFICE_CLIENT_ENV}
- - name: PROCESSOR_EMAIL_BOP_SKIP_USERS_RESOLUTION
- value: ${PROCESSOR_EMAIL_BOP_SKIP_USERS_RESOLUTION}
- name: PROCESSOR_EMAIL_BOP_URL
value: ${BACKOFFICE_SCHEME}://${BACKOFFICE_HOST}:${BACKOFFICE_PORT}/v1/sendEmails
- name: PROCESSOR_EMAIL_NO_REPLY
@@ -242,10 +240,6 @@ objects:
value: ${NOTIFICATIONS_DRAWER_ENABLED}
- name: NOTIFICATIONS_USE_MBOP_FOR_FETCHING_USERS
value: ${NOTIFICATIONS_USE_MBOP_FOR_FETCHING_USERS}
- - name: NOTIFICATIONS_WEBHOOK_CONNECTOR_ENABLED
- value: ${NOTIFICATIONS_WEBHOOK_CONNECTOR_ENABLED}
- - name: NOTIFICATIONS_EMAIL_CONNECTOR_ENABLED
- value: ${NOTIFICATIONS_EMAIL_CONNECTOR_ENABLED}
- name: NOTIFICATIONS_DRAWER_CONNECTOR_ENABLED
value: ${NOTIFICATIONS_DRAWER_CONNECTOR_ENABLED}
- name: NOTIFICATIONS_ASYNC_AGGREGATION_ENABLED
@@ -331,9 +325,6 @@ parameters:
- name: NOTIFICATIONS_LOG_LEVEL
description: Log level for com.redhat.cloud.notifications
value: INFO
-- name: PROCESSOR_EMAIL_BOP_SKIP_USERS_RESOLUTION
- description: Should BOP skip transforming usernames from our payload into email addresses using the IT Users Service?
- value: "false"
- name: QUARKUS_HIBERNATE_ORM_LOG_SQL
value: "false"
- name: QUARKUS_LOG_CLOUDWATCH_API_CALL_TIMEOUT
@@ -416,11 +407,6 @@ parameters:
value: "false"
- name: NOTIFICATIONS_USE_MBOP_FOR_FETCHING_USERS
value: "false"
-- name: NOTIFICATIONS_WEBHOOK_CONNECTOR_ENABLED
- value: "false"
-- name: NOTIFICATIONS_EMAIL_CONNECTOR_ENABLED
- description: Is the email connector enabled to process emails there instead of in the engine?
- value: "false"
- name: NOTIFICATIONS_DRAWER_CONNECTOR_ENABLED
description: Is the drawer connector enabled to process them instead of in the engine?
value: "false"
diff --git a/common/src/main/java/com/redhat/cloud/notifications/config/FeatureFlipper.java b/common/src/main/java/com/redhat/cloud/notifications/config/FeatureFlipper.java
index 4b83ba43e3..685b830190 100644
--- a/common/src/main/java/com/redhat/cloud/notifications/config/FeatureFlipper.java
+++ b/common/src/main/java/com/redhat/cloud/notifications/config/FeatureFlipper.java
@@ -80,21 +80,12 @@ public class FeatureFlipper {
@ConfigProperty(name = "notifications.use-mbop-for-fetching-users", defaultValue = "false")
boolean useMBOPForFetchingUsers;
- @ConfigProperty(name = "notifications.webhook-connector.enabled", defaultValue = "false")
- boolean webhookConnectorEnabled;
-
- @ConfigProperty(name = "notifications.email-connector.enabled", defaultValue = "false")
- boolean emailConnectorEnabled;
-
@ConfigProperty(name = "notifications.drawer-connector.enabled", defaultValue = "false")
boolean drawerConnectorEnabled;
@ConfigProperty(name = "notifications.async-aggregation.enabled", defaultValue = "true")
boolean asyncAggregation;
- @ConfigProperty(name = "processor.email.bop.skip-users-resolution", defaultValue = "false")
- boolean skipBopUsersResolution;
-
@ConfigProperty(name = "processor.email.aggregation.use-recipients-resolver-clowdapp.enabled", defaultValue = "false")
boolean useRecipientsResolverClowdappForDailyDigestEnabled;
@@ -114,11 +105,8 @@ void logFeaturesStatusAtStartup(@Observes StartupEvent event) {
Log.infof("The integration with the export service is %s", exportServiceIntegrationEnabled ? "enabled" : "disabled");
Log.infof("Drawer feature is %s", drawerEnabled ? "enabled" : "disabled");
Log.infof("The use of BOP/MBOP for fetching users is %s", useMBOPForFetchingUsers ? "enabled" : "disabled");
- Log.infof("The webhook connector is %s", webhookConnectorEnabled ? "enabled" : "disabled");
- Log.infof("The email connector is %s", emailConnectorEnabled ? "enabled" : "disabled");
Log.infof("The drawer connector is %s", drawerConnectorEnabled ? "enabled" : "disabled");
Log.infof("The async aggregation is %s", asyncAggregation ? "enabled" : "disabled");
- Log.infof("The BOP users resolution is %s", !skipBopUsersResolution ? "enabled" : "disabled");
Log.infof("The Recipients resolver usage for daily digest is %s", useRecipientsResolverClowdappForDailyDigestEnabled ? "enabled" : "disabled");
}
@@ -244,24 +232,6 @@ public void setUseMBOPForFetchingUsers(final boolean useMBOPForFetchingUsers) {
this.useMBOPForFetchingUsers = useMBOPForFetchingUsers;
}
- public boolean isWebhookConnectorEnabled() {
- return webhookConnectorEnabled;
- }
-
- public void setWebhookConnectorEnabled(boolean webhookConnectorEnabled) {
- checkTestLaunchMode();
- this.webhookConnectorEnabled = webhookConnectorEnabled;
- }
-
- public boolean isEmailConnectorEnabled() {
- return this.emailConnectorEnabled;
- }
-
- public void setEmailConnectorEnabled(final boolean emailConnectorEnabled) {
- checkTestLaunchMode();
- this.emailConnectorEnabled = emailConnectorEnabled;
- }
-
public boolean isDrawerConnectorEnabled() {
return drawerConnectorEnabled;
}
@@ -280,15 +250,6 @@ public void setAsyncAggregation(boolean asyncAggregation) {
this.asyncAggregation = asyncAggregation;
}
- public boolean isSkipBopUsersResolution() {
- return skipBopUsersResolution;
- }
-
- public void setSkipBopUsersResolution(boolean skipBopUsersResolution) {
- checkTestLaunchMode();
- this.skipBopUsersResolution = skipBopUsersResolution;
- }
-
public boolean isUseRecipientsResolverClowdappForDailyDigestEnabled() {
return useRecipientsResolverClowdappForDailyDigestEnabled;
}
diff --git a/engine/pom.xml b/engine/pom.xml
index 38aa7b7d87..1110e1b972 100644
--- a/engine/pom.xml
+++ b/engine/pom.xml
@@ -105,12 +105,6 @@
${apache.commons.csv.version}
-
-
- io.smallrye.reactive
- smallrye-mutiny-vertx-web-client
-
-
com.redhat.cloud.event
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/events/EndpointErrorFromConnectorHelper.java b/engine/src/main/java/com/redhat/cloud/notifications/events/EndpointErrorFromConnectorHelper.java
index a442e73ffd..12431381b1 100644
--- a/engine/src/main/java/com/redhat/cloud/notifications/events/EndpointErrorFromConnectorHelper.java
+++ b/engine/src/main/java/com/redhat/cloud/notifications/events/EndpointErrorFromConnectorHelper.java
@@ -1,7 +1,6 @@
package com.redhat.cloud.notifications.events;
import com.redhat.cloud.notifications.db.repositories.EndpointRepository;
-import com.redhat.cloud.notifications.db.repositories.NotificationHistoryRepository;
import com.redhat.cloud.notifications.models.Endpoint;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
@@ -31,9 +30,6 @@ public class EndpointErrorFromConnectorHelper {
@ConfigProperty(name = "processor.webhook.max-server-errors", defaultValue = "10")
int maxServerErrors;
- @Inject
- NotificationHistoryRepository notificationHistoryRepository;
-
private Counter disabledWebhooksServerErrorCount;
private Counter disabledWebhooksClientErrorCount;
public static final String CLIENT_TAG_VALUE = "client";
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/events/EndpointProcessor.java b/engine/src/main/java/com/redhat/cloud/notifications/events/EndpointProcessor.java
index 24f877c76d..a581a39433 100644
--- a/engine/src/main/java/com/redhat/cloud/notifications/events/EndpointProcessor.java
+++ b/engine/src/main/java/com/redhat/cloud/notifications/events/EndpointProcessor.java
@@ -1,7 +1,6 @@
package com.redhat.cloud.notifications.events;
import com.redhat.cloud.notifications.DelayedThrower;
-import com.redhat.cloud.notifications.config.FeatureFlipper;
import com.redhat.cloud.notifications.db.repositories.EndpointRepository;
import com.redhat.cloud.notifications.ingress.Action;
import com.redhat.cloud.notifications.models.Endpoint;
@@ -56,9 +55,6 @@ public class EndpointProcessor {
@Inject
EmailSubscriptionTypeProcessor emailProcessor;
- @Inject
- FeatureFlipper featureFlipper;
-
@Inject
SlackProcessor slackProcessor;
@@ -130,11 +126,7 @@ public void process(Event event) {
if (isAggregatorEvent(event)) {
emailProcessor.processAggregation(event);
} else {
- if (this.featureFlipper.isEmailConnectorEnabled()) {
- emailConnectorProcessor.process(event, endpointsByTypeEntry.getValue());
- } else {
- emailProcessor.process(event, endpointsByTypeEntry.getValue());
- }
+ emailConnectorProcessor.process(event, endpointsByTypeEntry.getValue());
}
break;
case WEBHOOK:
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/Email.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/email/Email.java
deleted file mode 100644
index 9f4d6d3fab..0000000000
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/Email.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.redhat.cloud.notifications.processors.email;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Input JSON format accepted by the BOP
- */
-public class Email {
- private String subject;
- private String body;
- private Set recipients;
- private Set ccList;
- private Set bccList;
- private String bodyType;
-
- public Email() {
- recipients = new HashSet<>();
- ccList = new HashSet<>();
- bccList = new HashSet<>();
- }
-
- public String getSubject() {
- return subject;
- }
-
- public void setSubject(String subject) {
- this.subject = subject;
- }
-
- public String getBody() {
- return body;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
-
- public Set getRecipients() {
- return recipients;
- }
-
- public void setRecipients(Set recipients) {
- this.recipients = recipients;
- }
-
- public Set getCcList() {
- return ccList;
- }
-
- public void setCcList(Set ccList) {
- this.ccList = ccList;
- }
-
- public Set getBccList() {
- return bccList;
- }
-
- public void setBccList(Set bccList) {
- this.bccList = bccList;
- }
-
- public String getBodyType() {
- return bodyType;
- }
-
- public void setBodyType(String bodyType) {
- this.bodyType = bodyType;
- }
-}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/EmailSender.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/email/EmailSender.java
deleted file mode 100644
index 0cdf703ebe..0000000000
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/EmailSender.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package com.redhat.cloud.notifications.processors.email;
-
-import com.redhat.cloud.notifications.config.FeatureFlipper;
-import com.redhat.cloud.notifications.events.EventWrapper;
-import com.redhat.cloud.notifications.ingress.Action;
-import com.redhat.cloud.notifications.models.Endpoint;
-import com.redhat.cloud.notifications.models.Event;
-import com.redhat.cloud.notifications.models.EventType;
-import com.redhat.cloud.notifications.models.NotificationHistory;
-import com.redhat.cloud.notifications.processors.webclient.BopWebClient;
-import com.redhat.cloud.notifications.processors.webhooks.WebhookTypeProcessor;
-import com.redhat.cloud.notifications.recipients.User;
-import com.redhat.cloud.notifications.recipients.mbop.Constants;
-import com.redhat.cloud.notifications.templates.TemplateService;
-import com.redhat.cloud.notifications.utils.LineBreakCleaner;
-import io.micrometer.core.instrument.MeterRegistry;
-import io.micrometer.core.instrument.Timer;
-import io.quarkus.logging.Log;
-import io.quarkus.qute.TemplateInstance;
-import io.vertx.core.json.JsonObject;
-import io.vertx.mutiny.core.buffer.Buffer;
-import io.vertx.mutiny.ext.web.client.HttpRequest;
-import io.vertx.mutiny.ext.web.client.WebClient;
-import jakarta.annotation.PostConstruct;
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.inject.Inject;
-import org.eclipse.microprofile.config.inject.ConfigProperty;
-
-import java.time.Duration;
-import java.time.LocalDateTime;
-import java.time.ZoneOffset;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-@ApplicationScoped
-public class EmailSender {
-
- static final String BODY_TYPE_HTML = "html";
- static final ZoneOffset UTC = ZoneOffset.UTC;
-
- @Inject
- @BopWebClient
- WebClient bopWebClient;
-
- @ConfigProperty(name = "processor.email.bop_url")
- String bopUrl;
-
- @ConfigProperty(name = "processor.email.bop_apitoken")
- String bopApiToken;
-
- @ConfigProperty(name = "processor.email.bop_client_id")
- String bopClientId;
-
- @ConfigProperty(name = "processor.email.bop_env")
- String bopEnv;
-
- @Inject
- FeatureFlipper featureFlipper;
-
- @Inject
- WebhookTypeProcessor webhookSender;
-
- @Inject
- TemplateService templateService;
-
- @Inject
- MeterRegistry registry;
-
- private Timer processTime;
-
- @PostConstruct
- public void init() {
- processTime = registry.timer("processor.email.process-time");
- /*
- * The token value we receive contains a line break because of the standard mime encryption. Gabor Burges tried
- * to remove it but that didn't work, so we have to do it here because Vert.x 4 does not allow line breaks in
- * HTTP headers.
- */
- bopApiToken = LineBreakCleaner.clean(bopApiToken);
- }
-
- public NotificationHistory sendEmail(Set users, Event event, TemplateInstance subject, TemplateInstance body, boolean persistHistory, Endpoint endpoint) {
-
- NotificationHistory history = null;
- if (users.isEmpty()) {
- Log.debug("No recipient found for this email");
- return history;
- }
-
- final HttpRequest bopRequest = this.buildBOPHttpRequest();
- LocalDateTime start = LocalDateTime.now(UTC);
-
- Timer.Sample processedTimer = Timer.start(registry);
-
- EventType eventType = event.getEventType();
- String bundleName = "NA";
- String applicationName = "NA";
- if (eventType != null) {
- bundleName = eventType.getApplication().getBundle().getName();
- applicationName = eventType.getApplication().getName();
- } else if (event.getEventWrapper().getEvent() instanceof Action action) {
- bundleName = action.getBundle();
- applicationName = action.getApplication();
- }
-
- // uses canonical EmailSubscription
- try {
-
- // TODO Add recipients processing from policies-notifications processing (failed recipients)
- // by checking the NotificationHistory's details section (if missing payload - fix in WebhookTypeProcessor)
-
- // TODO If the call fails - we should probably rollback Kafka topic (if BOP is down for example)
- // also add metrics for these failures
-
- history = webhookSender.doHttpRequest(
- event, endpoint,
- bopRequest,
- getPayload(users, event.getEventWrapper(), subject, body),
- "POST",
- bopUrl,
- persistHistory);
- return history;
- } catch (Exception e) {
- Log.error("Email sending failed", e);
- } finally {
- processedTimer.stop(registry.timer("processor.email.processed", "bundle", bundleName, "application", applicationName));
- processTime.record(Duration.between(start, LocalDateTime.now(UTC)));
- return history;
- }
- }
-
- private JsonObject getPayload(Set users, EventWrapper, ?> eventWrapper, TemplateInstance subject, TemplateInstance body) {
-
- String renderedSubject;
- String renderedBody;
- try {
- renderedSubject = templateService.renderTemplate(eventWrapper.getEvent(), subject);
- renderedBody = templateService.renderTemplate(eventWrapper.getEvent(), body);
- } catch (Exception e) {
- Log.warnf(e,
- "Unable to render template for %s.",
- eventWrapper.getKey().toString()
- );
- throw e;
- }
- if (featureFlipper.isSkipBopUsersResolution()) {
- SendEmailsRequest request = new SendEmailsRequest();
- request.addEmail(buildEmail(
- users,
- renderedSubject,
- renderedBody
- ));
- return JsonObject.mapFrom(request);
- } else {
- Emails emails = new Emails();
- emails.addEmail(buildEmail(
- users,
- renderedSubject,
- renderedBody
- ));
- return JsonObject.mapFrom(emails);
- }
- }
-
- protected HttpRequest buildBOPHttpRequest() {
- return bopWebClient
- .postAbs(bopUrl)
- .putHeader(Constants.MBOP_APITOKEN_HEADER, bopApiToken)
- .putHeader(Constants.MBOP_CLIENT_ID_HEADER, bopClientId)
- .putHeader(Constants.MBOP_ENV_HEADER, bopEnv);
- }
-
- protected Email buildEmail(Set recipients, String subject, String body) {
- Set usersEmail;
- if (featureFlipper.isSkipBopUsersResolution()) {
- usersEmail = recipients.stream().map(User::getEmail).collect(Collectors.toSet());
- } else {
- usersEmail = recipients.stream().map(User::getUsername).collect(Collectors.toSet());
- }
-
- Email email = new Email();
- email.setBodyType(BODY_TYPE_HTML);
- email.setBccList(usersEmail);
- email.setSubject(subject);
- email.setBody(body);
- return email;
- }
-}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/EmailSubscriptionTypeProcessor.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/email/EmailSubscriptionTypeProcessor.java
index ba9d87c73c..d918643ff6 100644
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/EmailSubscriptionTypeProcessor.java
+++ b/engine/src/main/java/com/redhat/cloud/notifications/processors/email/EmailSubscriptionTypeProcessor.java
@@ -6,7 +6,6 @@
import com.redhat.cloud.notifications.db.repositories.EmailAggregationRepository;
import com.redhat.cloud.notifications.db.repositories.EndpointRepository;
import com.redhat.cloud.notifications.db.repositories.EventRepository;
-import com.redhat.cloud.notifications.db.repositories.NotificationHistoryRepository;
import com.redhat.cloud.notifications.db.repositories.TemplateRepository;
import com.redhat.cloud.notifications.events.EventWrapperAction;
import com.redhat.cloud.notifications.ingress.Action;
@@ -20,9 +19,6 @@
import com.redhat.cloud.notifications.models.EndpointType;
import com.redhat.cloud.notifications.models.Event;
import com.redhat.cloud.notifications.models.EventType;
-import com.redhat.cloud.notifications.models.InstantEmailTemplate;
-import com.redhat.cloud.notifications.models.NotificationHistory;
-import com.redhat.cloud.notifications.models.NotificationStatus;
import com.redhat.cloud.notifications.models.SubscriptionType;
import com.redhat.cloud.notifications.processors.ConnectorSender;
import com.redhat.cloud.notifications.processors.SystemEndpointTypeProcessor;
@@ -47,7 +43,6 @@
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -55,13 +50,13 @@
import java.util.UUID;
import java.util.stream.Collectors;
-import static com.redhat.cloud.notifications.models.NotificationHistory.getHistoryStub;
-
+/*
+ * This class needs more cleanup but this will be done later to make the reviews easier.
+ * TODO Stop extending SystemEndpointTypeProcessor.
+ */
@ApplicationScoped
public class EmailSubscriptionTypeProcessor extends SystemEndpointTypeProcessor {
- public static final String TOTAL_RECIPIENTS_KEY = "total_recipients";
- public static final String TOTAL_FAILURE_RECIPIENTS_KEY = "total_failure_recipients";
public static final String AGGREGATION_COMMAND_REJECTED_COUNTER_NAME = "aggregation.command.rejected";
public static final String AGGREGATION_COMMAND_PROCESSED_COUNTER_NAME = "aggregation.command.processed";
public static final String AGGREGATION_COMMAND_ERROR_COUNTER_NAME = "aggregation.command.error";
@@ -79,9 +74,6 @@ public class EmailSubscriptionTypeProcessor extends SystemEndpointTypeProcessor
@Inject
EmailActorsResolver emailActorsResolver;
- @Inject
- EmailSender emailSender;
-
@Inject
EmailAggregator emailAggregator;
@@ -106,9 +98,6 @@ public class EmailSubscriptionTypeProcessor extends SystemEndpointTypeProcessor
@Inject
EndpointRepository endpointRepository;
- @Inject
- NotificationHistoryRepository notificationHistoryRepository;
-
@Inject
ApplicationRepository applicationRepository;
@@ -139,11 +128,7 @@ void postConstruct() {
@Override
public void process(Event event, List endpoints) {
- if (endpoints != null && !endpoints.isEmpty()) {
- this.generateAggregationWhereDue(event);
-
- sendEmail(event, Set.copyOf(endpoints));
- }
+ throw new UnsupportedOperationException("No longer used");
}
/**
@@ -175,26 +160,6 @@ public void generateAggregationWhereDue(final Event event) {
}
}
- private void sendEmail(Event event, Set endpoints) {
- final TemplateInstance subject;
- final TemplateInstance body;
-
- Optional instantEmailTemplate = templateRepository
- .findInstantEmailTemplate(event.getEventType().getId());
- if (instantEmailTemplate.isEmpty()) {
- return;
- } else {
- String subjectData = instantEmailTemplate.get().getSubjectTemplate().getData();
- subject = templateService.compileTemplate(subjectData, "subject");
- String bodyData = instantEmailTemplate.get().getBodyTemplate().getData();
- body = templateService.compileTemplate(bodyData, "body");
- }
- Endpoint endpoint = endpointRepository.getOrCreateDefaultSystemSubscription(event.getAccountId(), event.getOrgId(), EndpointType.EMAIL_SUBSCRIPTION);
-
- Set userList = getRecipientList(event, endpoints.stream().toList(), SubscriptionType.INSTANT);
- emailSender.sendEmail(userList, event, subject, body, true, endpoint);
- }
-
public void processAggregation(Event event) {
if (featureFlipper.isAsyncAggregation()) {
/*
@@ -265,7 +230,6 @@ public void processAggregationSync(Event event, boolean async) {
private void processAggregateEmailsByAggregationKey(AggregationCommand aggregationCommand, Optional aggregatorEvent, boolean async) {
TemplateInstance subject = null;
TemplateInstance body = null;
- final long startTime = System.currentTimeMillis();
EmailAggregationKey aggregationKey = aggregationCommand.getAggregationKey();
Optional aggregationEmailTemplate = templateRepository
@@ -301,8 +265,6 @@ private void processAggregateEmailsByAggregationKey(AggregationCommand aggregati
action.setEventType(event.getEventType().getName());
}
- Integer nbRecipientsSuccessfullySent = 0;
- Integer nbRecipientsFailureSent = 0;
if (subject != null && body != null) {
Map> aggregationsByUsers = emailAggregator.getAggregated(aggregationKey,
aggregationCommand.getSubscriptionType(),
@@ -319,43 +281,31 @@ private void processAggregateEmailsByAggregationKey(AggregationCommand aggregati
action.setContext(contextBuilder.build());
event.setEventWrapper(new EventWrapperAction(action));
- if (featureFlipper.isEmailConnectorEnabled()) {
- Set recipientsUsernames = aggregation.getValue().stream().map(User::getUsername).collect(Collectors.toSet());
- String subjectStr = templateService.renderTemplate(event.getEventWrapper().getEvent(), subject);
- String bodyStr = templateService.renderTemplate(event.getEventWrapper().getEvent(), body);
-
- Set recipientSettings = extractAndTransformRecipientSettings(event, List.of(endpoint));
-
- // Prepare all the data to be sent to the connector.
- final EmailNotification emailNotification = new EmailNotification(
- bodyStr,
- subjectStr,
- this.emailActorsResolver.getEmailSender(event),
- event.getOrgId(),
- recipientSettings,
- /*
- * The recipients are determined at an earlier stage (see EmailAggregator) using the
- * recipients-resolver app and the subscription records from the database.
- * The subscribedByDefault value below simply means that recipients-resolver will consider
- * the subscribers passed in the request as the recipients candidates of the aggregation email.
- */
- recipientsUsernames,
- Collections.emptySet(),
- false
- );
+ Set recipientsUsernames = aggregation.getValue().stream().map(User::getUsername).collect(Collectors.toSet());
+ String subjectStr = templateService.renderTemplate(event.getEventWrapper().getEvent(), subject);
+ String bodyStr = templateService.renderTemplate(event.getEventWrapper().getEvent(), body);
+
+ Set recipientSettings = extractAndTransformRecipientSettings(event, List.of(endpoint));
+
+ // Prepare all the data to be sent to the connector.
+ final EmailNotification emailNotification = new EmailNotification(
+ bodyStr,
+ subjectStr,
+ this.emailActorsResolver.getEmailSender(event),
+ event.getOrgId(),
+ recipientSettings,
+ /*
+ * The recipients are determined at an earlier stage (see EmailAggregator) using the
+ * recipients-resolver app and the subscription records from the database.
+ * The subscribedByDefault value below simply means that recipients-resolver will consider
+ * the subscribers passed in the request as the recipients candidates of the aggregation email.
+ */
+ recipientsUsernames,
+ Collections.emptySet(),
+ false
+ );
- connectorSender.send(event, endpoint, JsonObject.mapFrom(emailNotification));
- } else {
- NotificationHistory history = emailSender.sendEmail(aggregation.getValue(), event, subject, body, false, endpoint);
- if (history != null) {
- Integer totalRecipients = (Integer) history.getDetails().get(TOTAL_RECIPIENTS_KEY);
- if (NotificationStatus.SUCCESS == history.getStatus()) {
- nbRecipientsSuccessfullySent += totalRecipients;
- } else {
- nbRecipientsFailureSent += totalRecipients;
- }
- }
- }
+ connectorSender.send(event, endpoint, JsonObject.mapFrom(emailNotification));
}
}
@@ -363,30 +313,5 @@ private void processAggregateEmailsByAggregationKey(AggregationCommand aggregati
if (aggregationCommand.getSubscriptionType().equals(SubscriptionType.DAILY)) {
emailAggregationRepository.purgeOldAggregation(aggregationKey, aggregationCommand.getEnd());
}
-
- // build and persist aggregation history if needed.
- // If email connector is enabled, it will take care of history
- if (aggregatorEvent.isPresent() && !featureFlipper.isEmailConnectorEnabled()) {
- buildAggregatedHistory(startTime, endpoint, event, nbRecipientsSuccessfullySent, nbRecipientsFailureSent);
- }
- }
-
- private void buildAggregatedHistory(long startTime, Endpoint endpoint, Event event, Integer nbRecipientsSuccessfullySent, Integer nbRecipientsFailureSent) {
- long invocationTime = System.currentTimeMillis() - startTime;
- NotificationHistory history = getHistoryStub(endpoint, event, invocationTime, UUID.randomUUID());
- Map details = new HashMap<>();
- details.put(TOTAL_RECIPIENTS_KEY, nbRecipientsSuccessfullySent + nbRecipientsFailureSent);
- details.put(TOTAL_FAILURE_RECIPIENTS_KEY, nbRecipientsFailureSent);
- if (0 == nbRecipientsFailureSent) {
- history.setStatus(NotificationStatus.SUCCESS);
- } else {
- history.setStatus(NotificationStatus.FAILED_INTERNAL);
- }
- history.setDetails(details);
- try {
- notificationHistoryRepository.createNotificationHistory(history);
- } catch (Exception e) {
- Log.errorf(e, "Notification history creation failed for event %s and endpoint %s", event.getId(), history.getEndpoint());
- }
}
}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/Emails.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/email/Emails.java
deleted file mode 100644
index b1293e936c..0000000000
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/Emails.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.redhat.cloud.notifications.processors.email;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.HashSet;
-import java.util.Set;
-
-@Deprecated(forRemoval = true)
-public class Emails {
-
- @JsonProperty("emails")
- private final Set emails;
-
- Emails() {
- this.emails = new HashSet<>();
- }
-
- void addEmail(final Email email) {
- this.emails.add(email);
- }
-
- Set getEmails() {
- return emails;
- }
-}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/SendEmailsRequest.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/email/SendEmailsRequest.java
deleted file mode 100644
index 3efa4559df..0000000000
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/email/SendEmailsRequest.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.redhat.cloud.notifications.processors.email;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY;
-
-@JsonAutoDetect(fieldVisibility = ANY)
-public class SendEmailsRequest {
-
- private final Set emails = new HashSet<>();
- private final boolean skipUsersResolution = true;
-
- public void addEmail(Email email) {
- emails.add(email);
- }
-}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/BopWebClient.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/BopWebClient.java
deleted file mode 100644
index 3ee5c98593..0000000000
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/BopWebClient.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.redhat.cloud.notifications.processors.webclient;
-
-import jakarta.inject.Qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Use this qualifier to inject a {@link io.vertx.mutiny.ext.web.client.WebClient WebClient} instance to process BOP requests.
- */
-@Qualifier
-@Retention(RUNTIME)
-@Target({METHOD, FIELD})
-public @interface BopWebClient {
-}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/SslVerificationDisabled.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/SslVerificationDisabled.java
deleted file mode 100644
index 62d89ed070..0000000000
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/SslVerificationDisabled.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.redhat.cloud.notifications.processors.webclient;
-
-import jakarta.inject.Qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Use this qualifier to inject a {@link io.vertx.mutiny.ext.web.client.WebClient WebClient} instance that will trust
- * all SSL server certificates.
- */
-@Qualifier
-@Retention(RUNTIME)
-@Target({METHOD, FIELD})
-public @interface SslVerificationDisabled {
-}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/SslVerificationEnabled.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/SslVerificationEnabled.java
deleted file mode 100644
index 25bd8d9299..0000000000
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/SslVerificationEnabled.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.redhat.cloud.notifications.processors.webclient;
-
-import jakarta.inject.Qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Use this qualifier to inject a {@link io.vertx.mutiny.ext.web.client.WebClient WebClient} instance that will verify
- * SSL server certificates.
- */
-@Qualifier
-@Retention(RUNTIME)
-@Target({METHOD, FIELD})
-public @interface SslVerificationEnabled {
-}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/WebClientProducer.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/WebClientProducer.java
deleted file mode 100644
index 1f94a3a7d3..0000000000
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/webclient/WebClientProducer.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.redhat.cloud.notifications.processors.webclient;
-
-import io.quarkus.logging.Log;
-import io.vertx.ext.web.client.WebClientOptions;
-import io.vertx.mutiny.core.Vertx;
-import io.vertx.mutiny.ext.web.client.WebClient;
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.enterprise.inject.Produces;
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import org.eclipse.microprofile.config.inject.ConfigProperty;
-
-import java.util.Optional;
-
-@ApplicationScoped
-public class WebClientProducer {
-
- @Inject
- Vertx vertx;
-
- @ConfigProperty(name = "webclient.max_pool_size")
- Optional maxPoolSize;
-
- @Produces
- @Singleton
- @SslVerificationEnabled
- public WebClient securedWebClient() {
- return WebClient.create(vertx, buildOptions(false));
- }
-
- @Produces
- @Singleton
- @SslVerificationDisabled
- public WebClient unsecuredWebClient() {
- return WebClient.create(vertx, buildOptions(true));
- }
-
- @Produces
- @Singleton
- @BopWebClient
- public WebClient bopWebClient() {
- return WebClient.create(vertx, buildOptions(true));
- }
-
- private WebClientOptions buildOptions(boolean trustAll) {
- WebClientOptions options = new WebClientOptions()
- .setTrustAll(trustAll)
- .setConnectTimeout(3000); // TODO Should this be configurable by the system? We need a maximum in any case
- if (maxPoolSize.isPresent()) {
- Log.debugf("Producing a WebClient with a configured max pool size: %d", maxPoolSize.get());
- options = options.setMaxPoolSize(maxPoolSize.get());
- }
- return options;
- }
-}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/webhooks/ServerErrorException.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/webhooks/ServerErrorException.java
deleted file mode 100644
index 8345899a47..0000000000
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/webhooks/ServerErrorException.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.redhat.cloud.notifications.processors.webhooks;
-
-/**
- * This exception is thrown when the response of a webhook call contains a 5xx HTTP status.
- * Such status can be caused by a temporary remote issue so we should retry the call.
- */
-public class ServerErrorException extends RuntimeException {
-
- public ServerErrorException() {
- }
-}
diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/webhooks/WebhookTypeProcessor.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/webhooks/WebhookTypeProcessor.java
index dbb44eaddd..dc68cda4ed 100644
--- a/engine/src/main/java/com/redhat/cloud/notifications/processors/webhooks/WebhookTypeProcessor.java
+++ b/engine/src/main/java/com/redhat/cloud/notifications/processors/webhooks/WebhookTypeProcessor.java
@@ -2,89 +2,29 @@
import com.redhat.cloud.notifications.DelayedThrower;
import com.redhat.cloud.notifications.config.FeatureFlipper;
-import com.redhat.cloud.notifications.db.repositories.EndpointRepository;
-import com.redhat.cloud.notifications.events.IntegrationDisabledNotifier;
import com.redhat.cloud.notifications.models.Endpoint;
import com.redhat.cloud.notifications.models.Event;
-import com.redhat.cloud.notifications.models.NotificationHistory;
-import com.redhat.cloud.notifications.models.NotificationStatus;
import com.redhat.cloud.notifications.models.WebhookProperties;
import com.redhat.cloud.notifications.processors.ConnectorSender;
import com.redhat.cloud.notifications.processors.EndpointTypeProcessor;
-import com.redhat.cloud.notifications.processors.email.EmailSubscriptionTypeProcessor;
-import com.redhat.cloud.notifications.processors.webclient.SslVerificationDisabled;
-import com.redhat.cloud.notifications.processors.webclient.SslVerificationEnabled;
import com.redhat.cloud.notifications.routers.sources.SecretUtils;
import com.redhat.cloud.notifications.transformers.BaseTransformer;
-import dev.failsafe.Failsafe;
-import dev.failsafe.RetryPolicy;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
-import io.netty.channel.ConnectTimeoutException;
import io.quarkus.logging.Log;
-import io.vertx.core.VertxException;
-import io.vertx.core.http.HttpMethod;
import io.vertx.core.json.JsonObject;
-import io.vertx.mutiny.core.buffer.Buffer;
-import io.vertx.mutiny.ext.web.client.HttpRequest;
-import io.vertx.mutiny.ext.web.client.HttpResponse;
-import io.vertx.mutiny.ext.web.client.WebClient;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
-import org.eclipse.microprofile.config.inject.ConfigProperty;
-import java.io.IOException;
-import java.time.Duration;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.UUID;
import static com.redhat.cloud.notifications.events.EndpointProcessor.DELAYED_EXCEPTION_MSG;
-import static com.redhat.cloud.notifications.models.EndpointType.EMAIL_SUBSCRIPTION;
-import static com.redhat.cloud.notifications.models.NotificationHistory.getHistoryStub;
@ApplicationScoped
public class WebhookTypeProcessor extends EndpointTypeProcessor {
public static final String PROCESSED_WEBHOOK_COUNTER = "processor.webhook.processed";
- public static final String PROCESSED_EMAIL_COUNTER = "processor.email.processed";
- public static final String FAILED_WEBHOOK_COUNTER = "processor.webhook.failed";
- public static final String SUCCESSFUL_WEBHOOK_COUNTER = "processor.webhook.successful";
- public static final String FAILED_EMAIL_COUNTER = "processor.email.failed";
- public static final String RETRIED_WEBHOOK_COUNTER = "processor.webhook.retried";
- public static final String RETRIED_EMAIL_COUNTER = "processor.email.retried";
- public static final String SUCCESSFUL_EMAIL_COUNTER = "processor.email.successful";
- public static final String DISABLED_WEBHOOKS_COUNTER = "processor.webhook.disabled.endpoints";
- public static final String ERROR_TYPE_TAG_KEY = "error_type";
- public static final String CLIENT_TAG_VALUE = "client";
- public static final String SERVER_TAG_VALUE = "server";
- private static final String TOKEN_HEADER = "X-Insight-Token";
- private static final String CONNECTION_CLOSED_MSG = "Connection was closed";
-
- @ConfigProperty(name = "processor.webhook.retry.max-attempts", defaultValue = "3")
- int maxRetryAttempts;
-
- @ConfigProperty(name = "processor.webhook.retry.back-off.initial-value", defaultValue = "1S")
- Duration initialRetryBackOff;
-
- @ConfigProperty(name = "processor.webhook.retry.back-off.max-value", defaultValue = "30S")
- Duration maxRetryBackOff;
-
- @ConfigProperty(name = "processor.webhook.await-timeout", defaultValue = "60S")
- Duration awaitTimeout;
-
- @ConfigProperty(name = "processor.webhook.max-server-errors", defaultValue = "10")
- int maxServerErrors;
-
- @Inject
- @SslVerificationEnabled
- WebClient securedWebClient;
-
- @Inject
- @SslVerificationDisabled
- WebClient unsecuredWebClient;
@Inject
BaseTransformer transformer;
@@ -92,12 +32,6 @@ public class WebhookTypeProcessor extends EndpointTypeProcessor {
@Inject
FeatureFlipper featureFlipper;
- @Inject
- EndpointRepository endpointRepository;
-
- @Inject
- IntegrationDisabledNotifier integrationDisabledNotifier;
-
@Inject
MeterRegistry registry;
@@ -105,16 +39,6 @@ public class WebhookTypeProcessor extends EndpointTypeProcessor {
SecretUtils secretUtils;
private Counter processedWebhookCount;
- private Counter failedWebhookCount;
- private Counter retriedWebhookCount;
- private Counter successWebhookCount;
- private Counter processedEmailCount;
- private Counter failedEmailCount;
- private Counter retriedEmailCount;
- private Counter successEmailCount;
- private Counter disabledWebhooksClientErrorCount;
- private Counter disabledWebhooksServerErrorCount;
- private RetryPolicy