feat(api): add env toggles for automatic phone flagging (#2927)

This commit is contained in:
Hampus
2026-09-24 03:36:35 +02:00
committed by GitHub
parent 590b1f36fd
commit dcd5f09d6a
16 changed files with 268 additions and 6 deletions
+4
View File
@@ -277,6 +277,10 @@ function defaultConfig(): MasterConfig {
},
abuse_policy: {
inbound_phone_country_codes: [],
phone_flagging: {
enabled: true,
exempt_country_codes: [],
},
phone_verification: {
inbound_required_prefixes: [],
},
+4
View File
@@ -341,6 +341,10 @@ export interface MasterConfig {
};
abuse_policy: {
inbound_phone_country_codes: Array<string>;
phone_flagging: {
enabled: boolean;
exempt_country_codes: Array<string>;
};
phone_verification: {
inbound_required_prefixes: Array<string>;
};
@@ -464,6 +464,8 @@ describe('ConfigLoader', () => {
FLUXER_APP_STATUS_PAGE_INCIDENT_HISTORY_URL: 'https://status.example/history',
FLUXER_INSTANCE_SETUP_CONFIGURED: 'true',
FLUXER_ABUSE_INBOUND_PHONE_COUNTRY_CODES: 'AA,BB',
FLUXER_ABUSE_PHONE_FLAGGING_ENABLED: 'false',
FLUXER_ABUSE_PHONE_FLAGGING_EXEMPT_COUNTRY_CODES: 'CC,DD',
FLUXER_ABUSE_PHONE_INBOUND_REQUIRED_PREFIXES: '+101,+202',
FLUXER_ABUSE_DIRECT_CONTACT_SPAM_ENABLED: 'true',
FLUXER_ABUSE_DIRECT_CONTACT_SPAM_COUNTRY_CODES: 'AA,BB',
@@ -492,6 +494,10 @@ describe('ConfigLoader', () => {
expect(config.instance.setup.configured).toBe(true);
expect(config.instance.abuse_policy).toEqual({
inbound_phone_country_codes: ['AA', 'BB'],
phone_flagging: {
enabled: false,
exempt_country_codes: ['CC', 'DD'],
},
phone_verification: {
inbound_required_prefixes: ['+101', '+202'],
},
@@ -369,6 +369,14 @@ const NAMED_FLUXER_ENV_OVERRIDES: Record<string, NamedEnvOverride> = {
path: ['instance', 'abuse_policy', 'inbound_phone_country_codes'],
parse: parseCsv,
},
FLUXER_ABUSE_PHONE_FLAGGING_ENABLED: {
path: ['instance', 'abuse_policy', 'phone_flagging', 'enabled'],
parse: parseBoolean,
},
FLUXER_ABUSE_PHONE_FLAGGING_EXEMPT_COUNTRY_CODES: {
path: ['instance', 'abuse_policy', 'phone_flagging', 'exempt_country_codes'],
parse: parseCsv,
},
FLUXER_ABUSE_PHONE_INBOUND_REQUIRED_PREFIXES: {
path: ['instance', 'abuse_policy', 'phone_verification', 'inbound_required_prefixes'],
parse: parseCsv,