fix(guild): treat very high as high without phone verification (#3095)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-01 20:33:02 +02:00
1 parent d691047884
commit 2df82b2b5e
28 files changed
+289 -18

No files matched your search

@@ -2,6 +2,7 @@
import type {ChannelID, GuildID, RoleID, UserID} from '@app/api/BrandedTypes';
import {createChannelID, createGuildID, createRoleID, guildIdToRoleId} from '@app/api/BrandedTypes';
import {Config} from '@app/api/Config';
import type {IChannelRepository} from '@app/api/channel/IChannelRepository';
import {
type ChannelFollowerRemovalCopyMode,
@@ -481,6 +482,17 @@ export class GuildOperationsService {
ValidationErrorCodes.DISCOVERABLE_GUILD_VERIFICATION_LEVEL_TOO_LOW,
);
}
if (
data.verification_level === GuildVerificationLevel.VERY_HIGH &&
data.verification_level !== currentGuild.verificationLevel &&
!Config.instance.phoneVerificationEnabled
) {
throw InputValidationError.fromCode('verification_level', ValidationErrorCodes.VALUE_MUST_BE_INTEGER_IN_RANGE, {
name: 'verification_level',
minValue: GuildVerificationLevel.NONE,
maxValue: GuildVerificationLevel.HIGH,
});
}
const isMfaLevelChange = data.mfa_level !== undefined && data.mfa_level !== currentGuild.mfaLevel;
if (isMfaLevelChange) {
const isOwner = guildData.owner_id === userId.toString();
@@ -1177,7 +1189,12 @@ export class GuildOperationsService {
private sanitiseTemplateGuildSettings(template?: TemplateSerializedGuild): TemplateGuildSettings {
return {
verificationLevel: this.clampTemplateSetting(template?.verification_level, 0, 4, 0),
verificationLevel: this.clampTemplateSetting(
template?.verification_level,
GuildVerificationLevel.NONE,
Config.instance.phoneVerificationEnabled ? GuildVerificationLevel.VERY_HIGH : GuildVerificationLevel.HIGH,
GuildVerificationLevel.NONE,
),
explicitContentFilter: this.clampTemplateSetting(template?.explicit_content_filter, 0, 2, 0),
defaultMessageNotifications: this.clampTemplateSetting(template?.default_message_notifications, 0, 1, 0),
systemChannelFlags: (template?.system_channel_flags ?? 0) & SUPPORTED_SYSTEM_CHANNEL_FLAGS,