diff --git a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts index 5a1cc3e662..35ecf1d778 100644 --- a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts +++ b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts @@ -24,13 +24,13 @@ import { TopicGetOptions, } from './NotificationsStore'; import { - generateSettingsHash, Notification, NotificationSettings, notificationSeverities, NotificationSeverity, } from '@backstage/plugin-notifications-common'; import { Knex } from 'knex'; +import crypto from 'crypto'; const migrationsDir = resolvePackagePath( '@backstage/plugin-notifications-backend', @@ -106,6 +106,16 @@ export const normalizeSeverity = (input?: string): NotificationSeverity => { return lower; }; +export const generateSettingsHash = ( + user: string, + channel: string, + origin: string, + topic: string | null, +): string => { + const rawKey = `${user}|${channel}|${origin}|${topic ?? ''}`; + return crypto.createHash('sha256').update(rawKey).digest('hex'); +}; + /** @internal */ export class DatabaseNotificationsStore implements NotificationsStore { private readonly isSQLite = false; diff --git a/plugins/notifications-common/src/utils.ts b/plugins/notifications-common/src/utils.ts index 8017e8fd7c..b95df5bea5 100644 --- a/plugins/notifications-common/src/utils.ts +++ b/plugins/notifications-common/src/utils.ts @@ -14,7 +14,6 @@ * limitations under the License. */ import { NotificationSettings } from './types'; -import crypto from 'crypto'; /** @public */ export const isNotificationsEnabledFor = ( @@ -41,14 +40,3 @@ export const isNotificationsEnabledFor = ( } return topic.enabled; }; - -/** @public */ -export const generateSettingsHash = ( - user: string, - channel: string, - origin: string, - topic: string | null, -): string => { - const rawKey = `${user}|${channel}|${origin}|${topic ?? ''}`; - return crypto.createHash('sha256').update(rawKey).digest('hex'); -};