Skip to content

Commit

Permalink
fix: remove platform filter to be able to trigger platform alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
Okhelifi committed Aug 2, 2022
1 parent 80afcdb commit 90f837e
Showing 1 changed file with 4 additions and 30 deletions.
Expand Up @@ -15,8 +15,8 @@
*/
package io.gravitee.rest.api.service.impl;

import static io.gravitee.rest.api.service.common.GraviteeContext.ReferenceContextType.ENVIRONMENT;
import static io.gravitee.rest.api.service.common.GraviteeContext.ReferenceContextType.ORGANIZATION;
import static io.gravitee.rest.api.model.alert.AlertReferenceType.API;
import static io.gravitee.rest.api.model.alert.AlertReferenceType.APPLICATION;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toList;

Expand Down Expand Up @@ -542,34 +542,8 @@ public void accept(Notification notification) {
trigger.setFilters(filters);
}

switch (referenceType) {
case API:
case APPLICATION:
filters.add(StringCondition.equals(referenceType.name().toLowerCase(), referenceId).build());
break;
case PLATFORM:
// Add filters to make sure we will receive alert notifications only for events on the same organization / environment.
// For now, it seems that alerts are managed at organization level only. The behavior will change with https://github.com/gravitee-io/issues/issues/6079).
// It would be preferable to use a 'in' filter but this kind of filter does not exist yet. To keep backward compatibility we will rely on pattern matching.
filters.add(
StringCondition
.matches(
ORGANIZATION.name().toLowerCase(),
"(?:.*,|^)" + GraviteeContext.getCurrentOrganization() + "(?:,.*|$)|\\*",
true
)
.build()
);
filters.add(
StringCondition
.matches(
ENVIRONMENT.name().toLowerCase(),
"(?:.*|^)" + GraviteeContext.getCurrentEnvironment() + "(?:,.*|$)|\\*",
true
)
.build()
);
break;
if (referenceType == APPLICATION || referenceType == API) {
filters.add(StringCondition.equals(referenceType.name().toLowerCase(), referenceId).build());
}
}

Expand Down

0 comments on commit 90f837e

Please sign in to comment.