mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
bridgev2/provisionutil: allow mxids as participants in CreateGroup
This commit is contained in:
parent
56b182f85d
commit
36edccf61a
2 changed files with 8 additions and 2 deletions
|
|
@ -817,7 +817,8 @@ type GroupFieldCapability struct {
|
|||
type GroupCreateParams struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
|
||||
Username string `json:"username,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
// Clients may also provide MXIDs here, but provisionutil will normalize them, so bridges only need to handle network IDs
|
||||
Participants []networkid.UserID `json:"participants,omitempty"`
|
||||
Parent *networkid.PortalKey `json:"parent,omitempty"`
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,12 @@ func CreateGroup(ctx context.Context, login *bridgev2.UserLogin, params *bridgev
|
|||
return nil, bridgev2.RespError(mautrix.MInvalidParam.WithMessage("Must have at least %d members", typeSpec.Participants.MinLength))
|
||||
}
|
||||
userIDValidatingNetwork, uidValOK := login.Bridge.Network.(bridgev2.IdentifierValidatingNetwork)
|
||||
for _, participant := range params.Participants {
|
||||
for i, participant := range params.Participants {
|
||||
parsedParticipant, ok := login.Bridge.Matrix.ParseGhostMXID(id.UserID(participant))
|
||||
if ok {
|
||||
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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue