feat: add notifications filtering by processors
Signed-off-by: Yaron Dayagi <ydayagi@redhat.com>
This commit is contained in:
@@ -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 =
|
||||
| {
|
||||
|
||||
@@ -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[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user