bridgev2/provisioning: add option to skip identifier validation in create group
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run

This commit is contained in:
Tulir Asokan 2025-10-28 22:46:29 +02:00
commit 76cb8ee7d3
2 changed files with 8 additions and 2 deletions

View file

@ -826,6 +826,10 @@ type GroupFieldCapability struct {
// Only for the disappear field: allowed disappearing settings
DisappearSettings *event.DisappearingTimerCapability `json:"settings,omitempty"`
// This can be used to tell provisionutil not to call ValidateUserID on each participant.
// It only meant to allow hacks where ResolveIdentifier returns a fake ID that isn't actually valid for MXIDs.
SkipIdentifierValidation bool `json:"-"`
}
type GroupCreateParams struct {

View file

@ -47,8 +47,10 @@ func CreateGroup(ctx context.Context, login *bridgev2.UserLogin, params *bridgev
participant = parsedParticipant
params.Participants[i] = participant
}
if uidValOK && !userIDValidatingNetwork.ValidateUserID(participant) {
return nil, bridgev2.RespError(mautrix.MInvalidParam.WithMessage("User ID %q is not valid on this network", participant))
if !typeSpec.Participants.SkipIdentifierValidation {
if uidValOK && !userIDValidatingNetwork.ValidateUserID(participant) {
return nil, bridgev2.RespError(mautrix.MInvalidParam.WithMessage("User ID %q is not valid on this network", participant))
}
}
if api.IsThisUser(ctx, participant) {
return nil, bridgev2.RespError(mautrix.MInvalidParam.WithMessage("You can't include yourself in the participants list", participant))