Merge pull request #24731 from ydayagi/flpath1289

feat: add notifications filtering by processors
This commit is contained in:
Marek Libra
2024-05-22 12:50:53 +02:00
committed by GitHub
8 changed files with 137 additions and 6 deletions
+9
View File
@@ -8,6 +8,7 @@ import { DiscoveryService } from '@backstage/backend-plugin-api';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { Notification as Notification_2 } from '@backstage/plugin-notifications-common';
import { NotificationPayload } from '@backstage/plugin-notifications-common';
import { NotificationSeverity } from '@backstage/plugin-notifications-common';
import { ServiceRef } from '@backstage/backend-plugin-api';
// @public (undocumented)
@@ -23,6 +24,7 @@ export class DefaultNotificationService implements NotificationService {
// @public
export interface NotificationProcessor {
getName(): string;
getNotificationFilters?(): NotificationProcessorFilters;
postProcess?(
notification: Notification_2,
options: NotificationSendOptions,
@@ -36,6 +38,13 @@ export interface NotificationProcessor {
): Promise<NotificationSendOptions>;
}
// @public (undocumented)
export type NotificationProcessorFilters = {
minSeverity?: NotificationSeverity;
maxSeverity?: NotificationSeverity;
excludedTopics?: string[];
};
// @public (undocumented)
export type NotificationRecipients =
| {
+18 -1
View File
@@ -14,7 +14,10 @@
* limitations under the License.
*/
import { createExtensionPoint } from '@backstage/backend-plugin-api';
import { Notification } from '@backstage/plugin-notifications-common';
import {
Notification,
NotificationSeverity,
} from '@backstage/plugin-notifications-common';
import { NotificationSendOptions } from './service';
/**
@@ -90,6 +93,11 @@ export interface NotificationProcessor {
notification: Notification,
options: NotificationSendOptions,
): Promise<void>;
/**
* notification filters are used to call the processor only in certain conditions
*/
getNotificationFilters?(): NotificationProcessorFilters;
}
/**
@@ -108,3 +116,12 @@ export const notificationsProcessingExtensionPoint =
createExtensionPoint<NotificationsProcessingExtensionPoint>({
id: 'notifications.processing',
});
/**
* @public
*/
export type NotificationProcessorFilters = {
minSeverity?: NotificationSeverity;
maxSeverity?: NotificationSeverity;
excludedTopics?: string[];
};