mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 09:50:21 +08:00
feat: restructure notification services
This commit is contained in:
@@ -3,6 +3,10 @@ export interface ChatPiiRedactionFeatureSettings {
|
||||
inject_model_instruction: boolean
|
||||
}
|
||||
|
||||
export interface NotificationPushServiceFeatureSettings {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
export type FeatureSettingsMap = Record<string, unknown>
|
||||
|
||||
const DEFAULT_CHAT_PII_REDACTION_FEATURE_SETTINGS: ChatPiiRedactionFeatureSettings = {
|
||||
@@ -10,6 +14,10 @@ const DEFAULT_CHAT_PII_REDACTION_FEATURE_SETTINGS: ChatPiiRedactionFeatureSettin
|
||||
inject_model_instruction: true,
|
||||
}
|
||||
|
||||
const DEFAULT_NOTIFICATION_PUSH_SERVICE_FEATURE_SETTINGS: NotificationPushServiceFeatureSettings = {
|
||||
enabled: false,
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return !!value && typeof value === 'object' && !Array.isArray(value)
|
||||
}
|
||||
@@ -49,3 +57,30 @@ export function mergeChatPiiRedactionFeatureSettings(
|
||||
}
|
||||
return Object.keys(settings).length > 0 ? settings : null
|
||||
}
|
||||
|
||||
export function readNotificationPushServiceFeatureSettings(
|
||||
featureSettings: unknown,
|
||||
): NotificationPushServiceFeatureSettings {
|
||||
const feature = isRecord(featureSettings)
|
||||
? featureSettings.notification_push_service
|
||||
: null
|
||||
if (!isRecord(feature)) {
|
||||
return { ...DEFAULT_NOTIFICATION_PUSH_SERVICE_FEATURE_SETTINGS }
|
||||
}
|
||||
return {
|
||||
enabled: feature.enabled === true,
|
||||
}
|
||||
}
|
||||
|
||||
export function mergeNotificationPushServiceFeatureSettings(
|
||||
featureSettings: unknown,
|
||||
notificationPushService: NotificationPushServiceFeatureSettings,
|
||||
): FeatureSettingsMap | null {
|
||||
const settings: FeatureSettingsMap = isRecord(featureSettings)
|
||||
? { ...featureSettings }
|
||||
: {}
|
||||
settings.notification_push_service = {
|
||||
enabled: notificationPushService.enabled,
|
||||
}
|
||||
return Object.keys(settings).length > 0 ? settings : null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user