feat(experiments): ship seven treatments to everyone (#2798)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-15 18:03:35 +02:00
1 parent 9e614026d7
commit 910db6734b
167 files changed
+4608 -58147

No files matched your search

@@ -13,48 +13,13 @@ import {
DEFAULT_VOICE_NOISE_SUPPRESSION_CONFIG,
type VoiceNoiseSuppressionConfig,
} from '@fluxer/schema/src/domains/admin/VoiceNoiseSuppressionSchemas';
import {
type BlockedMessageGroupsConfig,
DEFAULT_BLOCKED_MESSAGE_GROUPS_CONFIG,
} from '@fluxer/schema/src/domains/experiment/BlockedMessageGroupsSchemas';
import {
DEFAULT_EXPERIMENT_DELIVERY_CONFIG,
type ExperimentDeliveryConfig,
} from '@fluxer/schema/src/domains/experiment/ExperimentSchemas';
import {
DEFAULT_EXPRESSION_INFO_CARD_CONFIG,
type ExpressionInfoCardConfig,
} from '@fluxer/schema/src/domains/experiment/ExpressionInfoCardSchemas';
import {
DEFAULT_GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG,
type GuildActivityLogPresentationConfig,
} from '@fluxer/schema/src/domains/experiment/GuildActivityLogPresentationSchemas';
import {
DEFAULT_GUILD_HEADER_COLLAPSE_CONFIG,
type GuildHeaderCollapseConfig,
} from '@fluxer/schema/src/domains/experiment/GuildHeaderCollapseSchemas';
import {
DEFAULT_MESSAGE_HOVER_TRACKING_CONFIG,
type MessageHoverTrackingConfig,
} from '@fluxer/schema/src/domains/experiment/MessageHoverTrackingSchemas';
import {
DEFAULT_MESSAGE_KEYBOARD_FOCUS_CONFIG,
type MessageKeyboardFocusConfig,
} from '@fluxer/schema/src/domains/experiment/MessageKeyboardFocusSchemas';
import {
DEFAULT_TYPING_INDICATOR_REWORK_CONFIG,
type TypingIndicatorReworkConfig,
} from '@fluxer/schema/src/domains/experiment/TypingIndicatorReworkSchemas';
import {afterEach, describe, expect, it, vi} from 'vitest';
const VOICE_NOISE_SUPPRESSION_CONFIG_KEY = 'voice_noise_suppression_config';
const MESSAGE_HOVER_TRACKING_CONFIG_KEY = 'message_hover_tracking_config';
const MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY = 'message_keyboard_focus_config';
const BLOCKED_MESSAGE_GROUPS_CONFIG_KEY = 'blocked_message_groups_config';
const GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG_KEY = 'guild_activity_log_presentation_config';
const EXPRESSION_INFO_CARD_CONFIG_KEY = 'expression_info_card_config';
const GUILD_HEADER_COLLAPSE_CONFIG_KEY = 'guild_header_collapse_config';
const TYPING_INDICATOR_REWORK_CONFIG_KEY = 'typing_indicator_rework_config';
const EXPERIMENT_DELIVERY_CONFIG_KEY = 'experiment_delivery_config';
const APP_PUBLIC_CONFIG_KEY = 'app_public_config';
const INSTANCE_POLICY_CONFIG_KEY = 'instance_policy_config';
@@ -347,363 +312,6 @@ describe('InstanceConfigRepository', () => {
await expect(repository.getVoiceNoiseSuppressionConfig()).resolves.toEqual(config);
});
it('returns the default message hover tracking config when the key is absent', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await expect(repository.getMessageHoverTrackingConfig()).resolves.toEqual(DEFAULT_MESSAGE_HOVER_TRACKING_CONFIG);
});
it.each([
{name: 'unparseable text', stored: 'not-json'},
{name: 'a json array', stored: '[]'},
{name: 'out-of-range values', stored: '{"rollout_basis_points":99999}'},
{name: 'a target that is not a snowflake', stored: '{"included_user_ids":["nope"]}'},
])('falls back to the default message hover tracking config for $name', async ({stored}) => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await repository.setConfig(MESSAGE_HOVER_TRACKING_CONFIG_KEY, stored);
await expect(repository.getMessageHoverTrackingConfig()).resolves.toEqual(DEFAULT_MESSAGE_HOVER_TRACKING_CONFIG);
});
it('round-trips a stored message hover tracking config', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
const config: MessageHoverTrackingConfig = {
...DEFAULT_MESSAGE_HOVER_TRACKING_CONFIG,
enabled: true,
config_version: 5,
rollout_basis_points: 2500,
rollout_salt: 'message-hover-tracking-v2',
included_user_ids: ['1400000000000000001'],
excluded_user_ids: ['1400000000000000002'],
};
await repository.setMessageHoverTrackingConfig(config);
await expect(repository.getMessageHoverTrackingConfig()).resolves.toEqual(config);
});
it('returns the default message keyboard focus config when the key is absent', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await expect(repository.getMessageKeyboardFocusConfig()).resolves.toEqual(DEFAULT_MESSAGE_KEYBOARD_FOCUS_CONFIG);
});
it.each([
{name: 'unparseable text', stored: 'not-json'},
{name: 'a json array', stored: '[]'},
{name: 'out-of-range values', stored: '{"rollout_basis_points":99999}'},
{name: 'a target that is not a snowflake', stored: '{"included_user_ids":["nope"]}'},
])('falls back to the default message keyboard focus config for $name', async ({stored}) => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await repository.setConfig(MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY, stored);
await expect(repository.getMessageKeyboardFocusConfig()).resolves.toEqual(DEFAULT_MESSAGE_KEYBOARD_FOCUS_CONFIG);
});
it('round-trips a stored message keyboard focus config', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
const config: MessageKeyboardFocusConfig = {
...DEFAULT_MESSAGE_KEYBOARD_FOCUS_CONFIG,
enabled: true,
config_version: 5,
rollout_basis_points: 2500,
rollout_salt: 'message-keyboard-focus-v2',
included_user_ids: ['1400000000000000001'],
excluded_user_ids: ['1400000000000000002'],
};
await repository.setMessageKeyboardFocusConfig(config);
await expect(repository.getMessageKeyboardFocusConfig()).resolves.toEqual(config);
});
it('returns the default blocked message groups config when the key is absent', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await expect(repository.getBlockedMessageGroupsConfig()).resolves.toEqual(DEFAULT_BLOCKED_MESSAGE_GROUPS_CONFIG);
});
it.each([
{name: 'unparseable text', stored: 'not-json'},
{name: 'a json array', stored: '[]'},
{name: 'out-of-range values', stored: '{"rollout_basis_points":99999}'},
{name: 'a target that is not a snowflake', stored: '{"included_user_ids":["nope"]}'},
])('falls back to the default blocked message groups config for $name', async ({stored}) => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await repository.setConfig(BLOCKED_MESSAGE_GROUPS_CONFIG_KEY, stored);
await expect(repository.getBlockedMessageGroupsConfig()).resolves.toEqual(DEFAULT_BLOCKED_MESSAGE_GROUPS_CONFIG);
});
it('round-trips a stored blocked message groups config', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
const config: BlockedMessageGroupsConfig = {
...DEFAULT_BLOCKED_MESSAGE_GROUPS_CONFIG,
enabled: true,
config_version: 5,
rollout_basis_points: 2500,
rollout_salt: 'blocked-message-groups-v2',
included_user_ids: ['1400000000000000001'],
excluded_user_ids: ['1400000000000000002'],
};
await repository.setBlockedMessageGroupsConfig(config);
await expect(repository.getBlockedMessageGroupsConfig()).resolves.toEqual(config);
});
it('returns the default guild activity log presentation config when the key is absent', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await expect(repository.getGuildActivityLogPresentationConfig()).resolves.toEqual(
DEFAULT_GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG,
);
});
it.each([
{name: 'unparseable text', stored: 'not-json'},
{name: 'a json array', stored: '[]'},
{name: 'out-of-range values', stored: '{"rollout_basis_points":99999}'},
{name: 'a target that is not a snowflake', stored: '{"included_user_ids":["nope"]}'},
])('falls back to the default guild activity log presentation config for $name', async ({stored}) => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await repository.setConfig(GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG_KEY, stored);
await expect(repository.getGuildActivityLogPresentationConfig()).resolves.toEqual(
DEFAULT_GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG,
);
});
it('round-trips a stored guild activity log presentation config', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
const config: GuildActivityLogPresentationConfig = {
...DEFAULT_GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG,
enabled: true,
config_version: 5,
rollout_basis_points: 2500,
rollout_salt: 'guild-activity-log-presentation-v2',
included_user_ids: ['1400000000000000001'],
excluded_user_ids: ['1400000000000000002'],
};
await repository.setGuildActivityLogPresentationConfig(config);
await expect(repository.getGuildActivityLogPresentationConfig()).resolves.toEqual(config);
});
it('returns the default expression info card config when the key is absent', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await expect(repository.getExpressionInfoCardConfig()).resolves.toEqual(DEFAULT_EXPRESSION_INFO_CARD_CONFIG);
});
it.each([
{name: 'unparseable text', stored: 'not-json'},
{name: 'a json array', stored: '[]'},
{name: 'out-of-range values', stored: '{"rollout_basis_points":99999}'},
{name: 'a target that is not a snowflake', stored: '{"included_user_ids":["nope"]}'},
])('falls back to the default expression info card config for $name', async ({stored}) => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await repository.setConfig(EXPRESSION_INFO_CARD_CONFIG_KEY, stored);
await expect(repository.getExpressionInfoCardConfig()).resolves.toEqual(DEFAULT_EXPRESSION_INFO_CARD_CONFIG);
});
it('round-trips a stored expression info card config', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
const config: ExpressionInfoCardConfig = {
...DEFAULT_EXPRESSION_INFO_CARD_CONFIG,
enabled: true,
config_version: 5,
rollout_basis_points: 2500,
rollout_salt: 'expression-info-card-v2',
included_user_ids: ['1400000000000000001'],
excluded_user_ids: ['1400000000000000002'],
};
await repository.setExpressionInfoCardConfig(config);
await expect(repository.getExpressionInfoCardConfig()).resolves.toEqual(config);
});
it('returns the default guild header collapse config when the key is absent', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await expect(repository.getGuildHeaderCollapseConfig()).resolves.toEqual(DEFAULT_GUILD_HEADER_COLLAPSE_CONFIG);
});
it.each([
{name: 'unparseable text', stored: 'not-json'},
{name: 'a json array', stored: '[]'},
{name: 'out-of-range values', stored: '{"rollout_basis_points":99999}'},
{name: 'a target that is not a snowflake', stored: '{"included_user_ids":["nope"]}'},
])('falls back to the default guild header collapse config for $name', async ({stored}) => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await repository.setConfig(GUILD_HEADER_COLLAPSE_CONFIG_KEY, stored);
await expect(repository.getGuildHeaderCollapseConfig()).resolves.toEqual(DEFAULT_GUILD_HEADER_COLLAPSE_CONFIG);
});
it('round-trips a stored guild header collapse config', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
const config: GuildHeaderCollapseConfig = {
...DEFAULT_GUILD_HEADER_COLLAPSE_CONFIG,
enabled: true,
config_version: 5,
rollout_basis_points: 1500,
rollout_salt: 'guild-header-collapse-v2',
included_user_ids: ['1400000000000000001'],
excluded_user_ids: ['1400000000000000002'],
};
await repository.setGuildHeaderCollapseConfig(config);
await expect(repository.getGuildHeaderCollapseConfig()).resolves.toEqual(config);
});
it('fills newly added guild header collapse fields from the schema defaults', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await repository.setConfig(
GUILD_HEADER_COLLAPSE_CONFIG_KEY,
JSON.stringify({enabled: true, config_version: 2, rollout_basis_points: 1000}),
);
await expect(repository.getGuildHeaderCollapseConfig()).resolves.toEqual({
...DEFAULT_GUILD_HEADER_COLLAPSE_CONFIG,
enabled: true,
config_version: 2,
rollout_basis_points: 1000,
});
});
it('returns the default typing indicator rework config when the key is absent', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await expect(repository.getTypingIndicatorReworkConfig()).resolves.toEqual(DEFAULT_TYPING_INDICATOR_REWORK_CONFIG);
});
it.each([
{name: 'unparseable text', stored: 'not-json'},
{name: 'a json array', stored: '[]'},
{name: 'out-of-range values', stored: '{"rollout_basis_points":99999}'},
{name: 'a target that is not a snowflake', stored: '{"included_user_ids":["nope"]}'},
])('falls back to the default typing indicator rework config for $name', async ({stored}) => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await repository.setConfig(TYPING_INDICATOR_REWORK_CONFIG_KEY, stored);
await expect(repository.getTypingIndicatorReworkConfig()).resolves.toEqual(DEFAULT_TYPING_INDICATOR_REWORK_CONFIG);
});
it('round-trips a stored typing indicator rework config', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
const config: TypingIndicatorReworkConfig = {
...DEFAULT_TYPING_INDICATOR_REWORK_CONFIG,
enabled: true,
config_version: 5,
rollout_basis_points: 1500,
rollout_salt: 'typing-indicator-rework-v2',
included_user_ids: ['1400000000000000001'],
excluded_user_ids: ['1400000000000000002'],
};
await repository.setTypingIndicatorReworkConfig(config);
await expect(repository.getTypingIndicatorReworkConfig()).resolves.toEqual(config);
});
it('fills newly added typing indicator rework fields from the schema defaults', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
await repository.setConfig(
TYPING_INDICATOR_REWORK_CONFIG_KEY,
JSON.stringify({enabled: true, config_version: 2, rollout_basis_points: 1000}),
);
await expect(repository.getTypingIndicatorReworkConfig()).resolves.toEqual({
...DEFAULT_TYPING_INDICATOR_REWORK_CONFIG,
enabled: true,
config_version: 2,
rollout_basis_points: 1000,
});
});
it('fills newly added voice noise suppression fields from the schema defaults', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
@@ -32,38 +32,10 @@ import {
type VoiceNoiseSuppressionConfig,
VoiceNoiseSuppressionConfigSchema,
} from '@fluxer/schema/src/domains/admin/VoiceNoiseSuppressionSchemas';
import {
type BlockedMessageGroupsConfig,
BlockedMessageGroupsConfigSchema,
} from '@fluxer/schema/src/domains/experiment/BlockedMessageGroupsSchemas';
import {
type ExperimentDeliveryConfig,
ExperimentDeliveryConfigSchema,
} from '@fluxer/schema/src/domains/experiment/ExperimentSchemas';
import {
type ExpressionInfoCardConfig,
ExpressionInfoCardConfigSchema,
} from '@fluxer/schema/src/domains/experiment/ExpressionInfoCardSchemas';
import {
type GuildActivityLogPresentationConfig,
GuildActivityLogPresentationConfigSchema,
} from '@fluxer/schema/src/domains/experiment/GuildActivityLogPresentationSchemas';
import {
type GuildHeaderCollapseConfig,
GuildHeaderCollapseConfigSchema,
} from '@fluxer/schema/src/domains/experiment/GuildHeaderCollapseSchemas';
import {
type MessageHoverTrackingConfig,
MessageHoverTrackingConfigSchema,
} from '@fluxer/schema/src/domains/experiment/MessageHoverTrackingSchemas';
import {
type MessageKeyboardFocusConfig,
MessageKeyboardFocusConfigSchema,
} from '@fluxer/schema/src/domains/experiment/MessageKeyboardFocusSchemas';
import {
type TypingIndicatorReworkConfig,
TypingIndicatorReworkConfigSchema,
} from '@fluxer/schema/src/domains/experiment/TypingIndicatorReworkSchemas';
import {
type InstanceAppPublic,
InstanceAppPublicSchema,
@@ -82,14 +54,7 @@ import {z} from 'zod';
const GATEWAY_ROLLOUT_CONFIG_KEY = 'gateway_rollout_config';
const VOICE_NOISE_SUPPRESSION_CONFIG_KEY = 'voice_noise_suppression_config';
const GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG_KEY = 'guild_activity_log_presentation_config';
const EXPERIMENT_DELIVERY_CONFIG_KEY = 'experiment_delivery_config';
const MESSAGE_HOVER_TRACKING_CONFIG_KEY = 'message_hover_tracking_config';
const MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY = 'message_keyboard_focus_config';
const BLOCKED_MESSAGE_GROUPS_CONFIG_KEY = 'blocked_message_groups_config';
const EXPRESSION_INFO_CARD_CONFIG_KEY = 'expression_info_card_config';
const GUILD_HEADER_COLLAPSE_CONFIG_KEY = 'guild_header_collapse_config';
const TYPING_INDICATOR_REWORK_CONFIG_KEY = 'typing_indicator_rework_config';
const REGISTRATION_CONFIG_KEY = 'registration_config';
const REGISTRATION_URLS_KEY = 'registration_urls';
const REGISTRATION_PENDING_APPROVALS_KEY = 'registration_pending_approvals';
@@ -372,14 +337,7 @@ type StoredConfigSection =
| 'app public'
| 'gateway rollout'
| 'voice noise suppression'
| 'guild activity log presentation'
| 'experiment delivery'
| 'message hover tracking'
| 'message keyboard focus'
| 'blocked message groups'
| 'expression info card'
| 'guild header collapse'
| 'typing indicator rework'
| 'instance policy'
| 'integrations'
| 'media'
@@ -517,38 +475,10 @@ function parseStoredVoiceNoiseSuppressionConfig(raw: string | null): VoiceNoiseS
return parseStoredConfigOrDefault(VoiceNoiseSuppressionConfigSchema, raw, 'voice noise suppression');
}
function parseStoredGuildActivityLogPresentationConfig(raw: string | null): GuildActivityLogPresentationConfig {
return parseStoredConfigOrDefault(GuildActivityLogPresentationConfigSchema, raw, 'guild activity log presentation');
}
function parseStoredExperimentDeliveryConfig(raw: string | null): ExperimentDeliveryConfig {
return parseStoredConfigOrDefault(ExperimentDeliveryConfigSchema, raw, 'experiment delivery');
}
function parseStoredMessageHoverTrackingConfig(raw: string | null): MessageHoverTrackingConfig {
return parseStoredConfigOrDefault(MessageHoverTrackingConfigSchema, raw, 'message hover tracking');
}
function parseStoredMessageKeyboardFocusConfig(raw: string | null): MessageKeyboardFocusConfig {
return parseStoredConfigOrDefault(MessageKeyboardFocusConfigSchema, raw, 'message keyboard focus');
}
function parseStoredBlockedMessageGroupsConfig(raw: string | null): BlockedMessageGroupsConfig {
return parseStoredConfigOrDefault(BlockedMessageGroupsConfigSchema, raw, 'blocked message groups');
}
function parseStoredExpressionInfoCardConfig(raw: string | null): ExpressionInfoCardConfig {
return parseStoredConfigOrDefault(ExpressionInfoCardConfigSchema, raw, 'expression info card');
}
function parseStoredGuildHeaderCollapseConfig(raw: string | null): GuildHeaderCollapseConfig {
return parseStoredConfigOrDefault(GuildHeaderCollapseConfigSchema, raw, 'guild header collapse');
}
function parseStoredTypingIndicatorReworkConfig(raw: string | null): TypingIndicatorReworkConfig {
return parseStoredConfigOrDefault(TypingIndicatorReworkConfigSchema, raw, 'typing indicator rework');
}
function validateStoredCollection<T>(schema: z.ZodType<T>, value: unknown, section: StoredConfigSection): Array<T> {
if (!Array.isArray(value)) {
throw new Error(`Stored ${section} configuration must be an array`);
@@ -1067,14 +997,7 @@ export class InstanceConfigRepository {
parseStoredGatewayRolloutConfig(snapshot.get(GATEWAY_ROLLOUT_CONFIG_KEY) ?? null),
);
parseStoredVoiceNoiseSuppressionConfig(snapshot.get(VOICE_NOISE_SUPPRESSION_CONFIG_KEY) ?? null);
parseStoredGuildActivityLogPresentationConfig(snapshot.get(GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG_KEY) ?? null);
parseStoredExperimentDeliveryConfig(snapshot.get(EXPERIMENT_DELIVERY_CONFIG_KEY) ?? null);
parseStoredMessageHoverTrackingConfig(snapshot.get(MESSAGE_HOVER_TRACKING_CONFIG_KEY) ?? null);
parseStoredMessageKeyboardFocusConfig(snapshot.get(MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY) ?? null);
parseStoredBlockedMessageGroupsConfig(snapshot.get(BLOCKED_MESSAGE_GROUPS_CONFIG_KEY) ?? null);
parseStoredExpressionInfoCardConfig(snapshot.get(EXPRESSION_INFO_CARD_CONFIG_KEY) ?? null);
parseStoredGuildHeaderCollapseConfig(snapshot.get(GUILD_HEADER_COLLAPSE_CONFIG_KEY) ?? null);
parseStoredTypingIndicatorReworkConfig(snapshot.get(TYPING_INDICATOR_REWORK_CONFIG_KEY) ?? null);
const policy = parseStoredInstancePolicyConfig(snapshot.get(INSTANCE_POLICY_CONFIG_KEY) ?? null);
checkStoredConfig('registration', () =>
parseStoredRegistrationConfig(snapshot.get(REGISTRATION_CONFIG_KEY) ?? null),
@@ -1155,85 +1078,11 @@ export class InstanceConfigRepository {
await this.setConfig(VOICE_NOISE_SUPPRESSION_CONFIG_KEY, JSON.stringify(validated));
}
async getGuildActivityLogPresentationConfig(): Promise<GuildActivityLogPresentationConfig> {
const raw = await this.getConfig(GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG_KEY);
return parseStoredGuildActivityLogPresentationConfig(raw);
}
async setGuildActivityLogPresentationConfig(config: GuildActivityLogPresentationConfig): Promise<void> {
const validated = validateStoredConfig(
GuildActivityLogPresentationConfigSchema,
config,
'guild activity log presentation',
);
await this.setConfig(GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG_KEY, JSON.stringify(validated));
}
async getExperimentDeliveryConfig(): Promise<ExperimentDeliveryConfig> {
const raw = await this.getConfig(EXPERIMENT_DELIVERY_CONFIG_KEY);
return parseStoredExperimentDeliveryConfig(raw);
}
async getMessageHoverTrackingConfig(): Promise<MessageHoverTrackingConfig> {
const raw = await this.getConfig(MESSAGE_HOVER_TRACKING_CONFIG_KEY);
return parseStoredMessageHoverTrackingConfig(raw);
}
async setMessageHoverTrackingConfig(config: MessageHoverTrackingConfig): Promise<void> {
const validated = validateStoredConfig(MessageHoverTrackingConfigSchema, config, 'message hover tracking');
await this.setConfig(MESSAGE_HOVER_TRACKING_CONFIG_KEY, JSON.stringify(validated));
}
async getMessageKeyboardFocusConfig(): Promise<MessageKeyboardFocusConfig> {
const raw = await this.getConfig(MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY);
return parseStoredMessageKeyboardFocusConfig(raw);
}
async setMessageKeyboardFocusConfig(config: MessageKeyboardFocusConfig): Promise<void> {
const validated = validateStoredConfig(MessageKeyboardFocusConfigSchema, config, 'message keyboard focus');
await this.setConfig(MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY, JSON.stringify(validated));
}
async getBlockedMessageGroupsConfig(): Promise<BlockedMessageGroupsConfig> {
const raw = await this.getConfig(BLOCKED_MESSAGE_GROUPS_CONFIG_KEY);
return parseStoredBlockedMessageGroupsConfig(raw);
}
async setBlockedMessageGroupsConfig(config: BlockedMessageGroupsConfig): Promise<void> {
const validated = validateStoredConfig(BlockedMessageGroupsConfigSchema, config, 'blocked message groups');
await this.setConfig(BLOCKED_MESSAGE_GROUPS_CONFIG_KEY, JSON.stringify(validated));
}
async getExpressionInfoCardConfig(): Promise<ExpressionInfoCardConfig> {
const raw = await this.getConfig(EXPRESSION_INFO_CARD_CONFIG_KEY);
return parseStoredExpressionInfoCardConfig(raw);
}
async setExpressionInfoCardConfig(config: ExpressionInfoCardConfig): Promise<void> {
const validated = validateStoredConfig(ExpressionInfoCardConfigSchema, config, 'expression info card');
await this.setConfig(EXPRESSION_INFO_CARD_CONFIG_KEY, JSON.stringify(validated));
}
async getGuildHeaderCollapseConfig(): Promise<GuildHeaderCollapseConfig> {
const raw = await this.getConfig(GUILD_HEADER_COLLAPSE_CONFIG_KEY);
return parseStoredGuildHeaderCollapseConfig(raw);
}
async setGuildHeaderCollapseConfig(config: GuildHeaderCollapseConfig): Promise<void> {
const validated = validateStoredConfig(GuildHeaderCollapseConfigSchema, config, 'guild header collapse');
await this.setConfig(GUILD_HEADER_COLLAPSE_CONFIG_KEY, JSON.stringify(validated));
}
async getTypingIndicatorReworkConfig(): Promise<TypingIndicatorReworkConfig> {
const raw = await this.getConfig(TYPING_INDICATOR_REWORK_CONFIG_KEY);
return parseStoredTypingIndicatorReworkConfig(raw);
}
async setTypingIndicatorReworkConfig(config: TypingIndicatorReworkConfig): Promise<void> {
const validated = validateStoredConfig(TypingIndicatorReworkConfigSchema, config, 'typing indicator rework');
await this.setConfig(TYPING_INDICATOR_REWORK_CONFIG_KEY, JSON.stringify(validated));
}
async setExperimentDeliveryConfig(config: ExperimentDeliveryConfig): Promise<void> {
const validated = validateStoredConfig(ExperimentDeliveryConfigSchema, config, 'experiment delivery');
await this.setConfig(EXPERIMENT_DELIVERY_CONFIG_KEY, JSON.stringify(validated));