mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
Merge 6d1c47d2a0
into a408b24d28
This commit is contained in:
commit
fdace1a129
2 changed files with 28 additions and 2 deletions
|
@ -2330,8 +2330,23 @@ func TestCreateRoomInvite(t *testing.T) {
|
|||
|
||||
roomID := gjson.GetBytes(w.Body.Bytes(), "room_id").Str
|
||||
validRoomID, _ := spec.NewRoomID(roomID)
|
||||
|
||||
// Confirm that the room matches the private state preset
|
||||
ev, err := rsAPI.CurrentStateEvent(context.Background(), *validRoomID, spec.MRoomJoinRules, spec.Invite)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ev, err = rsAPI.CurrentStateEvent(context.Background(), *validRoomID, spec.MRoomHistoryVisibility, string(gomatrixserverlib.HistoryVisibilityShared))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ev, err = rsAPI.CurrentStateEvent(context.Background(), *validRoomID, spec.MRoomGuestAccess, "can_join")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Now ask the roomserver about the membership event of Bob
|
||||
ev, err := rsAPI.CurrentStateEvent(context.Background(), *validRoomID, spec.MRoomMember, bob.ID)
|
||||
ev, err = rsAPI.CurrentStateEvent(context.Background(), *validRoomID, spec.MRoomMember, bob.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -114,6 +114,18 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
|||
}
|
||||
|
||||
var guestsCanJoin bool
|
||||
|
||||
// If unspecified, the server should use the visibility to determine which preset to use.
|
||||
// A visibility of public equates to a preset of public_chat
|
||||
// and private visibility equates to a preset of private_chat.
|
||||
if createRequest.StatePreset == "" {
|
||||
switch createRequest.Visibility {
|
||||
case "private", "":
|
||||
createRequest.StatePreset = spec.PresetPrivateChat
|
||||
case "public":
|
||||
createRequest.StatePreset = spec.PresetPublicChat
|
||||
}
|
||||
}
|
||||
switch createRequest.StatePreset {
|
||||
case spec.PresetPrivateChat:
|
||||
joinRuleContent.JoinRule = spec.Invite
|
||||
|
@ -130,7 +142,6 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
|||
joinRuleContent.JoinRule = spec.Public
|
||||
historyVisibilityContent.HistoryVisibility = historyVisibilityShared
|
||||
}
|
||||
|
||||
createEvent := gomatrixserverlib.FledglingEvent{
|
||||
Type: spec.MRoomCreate,
|
||||
Content: createContent,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue