Skip to content

Issue/createroom api behavior does not match spec #3562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion clientapi/clientapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2330,8 +2330,23 @@

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)

Check failure on line 2335 in clientapi/clientapi_test.go

View workflow job for this annotation

GitHub Actions / Linting

SA4006: this value of `ev` is never used (staticcheck)
if err != nil {
t.Fatal(err)
}
ev, err = rsAPI.CurrentStateEvent(context.Background(), *validRoomID, spec.MRoomHistoryVisibility, string(gomatrixserverlib.HistoryVisibilityShared))

Check failure on line 2339 in clientapi/clientapi_test.go

View workflow job for this annotation

GitHub Actions / Linting

SA4006: this value of `ev` is never used (staticcheck)
if err != nil {
t.Fatal(err)
}
ev, err = rsAPI.CurrentStateEvent(context.Background(), *validRoomID, spec.MRoomGuestAccess, "can_join")

Check failure on line 2343 in clientapi/clientapi_test.go

View workflow job for this annotation

GitHub Actions / Linting

SA4006: this value of `ev` is never used (staticcheck)
if err != nil {
t.Fatal(err)
}
Comment on lines +2335 to +2346
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to check the content of the state events here, as currently we don't use ev at all. (except the check if bob has a displayname below)


// 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)
}
Expand Down
13 changes: 12 additions & 1 deletion roomserver/internal/perform/perform_create_room.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
Loading