diff --git a/src/main/java/io/github/hikingc/matrixsdk/api/Room.java b/src/main/java/io/github/hikingc/matrixsdk/api/Room.java index 6c302d8..8469aaf 100644 --- a/src/main/java/io/github/hikingc/matrixsdk/api/Room.java +++ b/src/main/java/io/github/hikingc/matrixsdk/api/Room.java @@ -6,7 +6,6 @@ import io.github.hikingc.matrixsdk.api.rooms.*; import io.github.hikingc.matrixsdk.api.rooms.models.ResolvedAlias; import io.github.hikingc.matrixsdk.api.rooms.models.RoomSummary; -import io.github.hikingc.matrixsdk.api.rooms.queries.CreationRoomType; import io.github.hikingc.matrixsdk.api.rooms.queries.JoinRoomRequest; import io.github.hikingc.matrixsdk.api.rooms.queries.VisibilityRoomType; import io.github.hikingc.matrixsdk.exceptions.MatrixIOException; @@ -21,25 +20,13 @@ /// @see Matrix Client-Server API /// Specification for Rooms public interface Room { - /// Creates a room, this method will let the homeserver choose the default configuration for most - /// tasks and the following parameters will overwrite them if set to a non-null value. - /// - /// @param isFederated if the room will be federated - /// @param name the room's name, if any. - /// @param aliasName the room's canonical alias, if any - /// @param topic the room's topic, if any. - /// @param type the [CreationRoomType] - /// @param isVisible if the room will be visible to the public + /// Creates a room based on the received [InitialRoomConfiguration]. + /// + /// @param configuration of the room. /// @return the created room’s ID. /// @throws MatrixIOException when the payload cannot be processed /// @throws MatrixNetworkException when the response status is not successful - String create( - boolean isFederated, - String name, - String aliasName, - String topic, - CreationRoomType type, - boolean isVisible); + String create(InitialRoomConfiguration configuration); /// Requests the server to resolve a room alias if not possible, the server will use the /// federation API. @@ -184,7 +171,7 @@ String joinByRoomIdOrAliasIfAllowed( /// @param since a pagination token from a previous request, allowing you to get the next or /// previous batch of rooms. The direction of pagination is specified by which token is /// supplied. - /// @return a [PublicRoomDirectory] containing [PublishedRoomsChunk] records of the published + /// @return a [PublicRoomDirectory] containing [io.github.hikingc.matrixsdk.api.rooms.models.PublishedRoomsChunk] records of the published /// rooms on the server. /// @throws MatrixIOException when the payload cannot be processed. /// @throws NullPointerException when the roomId is null. @@ -195,7 +182,7 @@ String joinByRoomIdOrAliasIfAllowed( /// Lists a server’s published room directory. /// /// @param request a [PublicRoomRequest] with additional filters for the request. - /// @return a [PublicRoomDirectory] containing [PublishedRoomsChunk] records of the published + /// @return a [PublicRoomDirectory] containing [io.github.hikingc.matrixsdk.api.rooms.models.PublishedRoomsChunk] records of the published /// rooms on the server. PublicRoomDirectory getPublishedRoomDirectory(PublicRoomRequest request); diff --git a/src/main/java/io/github/hikingc/matrixsdk/api/events/content/RoomPowerLevels.java b/src/main/java/io/github/hikingc/matrixsdk/api/events/content/RoomPowerLevels.java index 399f1f1..8b6cf25 100644 --- a/src/main/java/io/github/hikingc/matrixsdk/api/events/content/RoomPowerLevels.java +++ b/src/main/java/io/github/hikingc/matrixsdk/api/events/content/RoomPowerLevels.java @@ -14,7 +14,7 @@ public record RoomPowerLevels( Integer redact, Integer stateDefault, Map users, - Integer users_default) + Integer usersDefault) implements StateEventContent { public record Notifications( diff --git a/src/main/java/io/github/hikingc/matrixsdk/api/rooms/InitialRoomConfiguration.java b/src/main/java/io/github/hikingc/matrixsdk/api/rooms/InitialRoomConfiguration.java new file mode 100644 index 0000000..f29039e --- /dev/null +++ b/src/main/java/io/github/hikingc/matrixsdk/api/rooms/InitialRoomConfiguration.java @@ -0,0 +1,97 @@ +package io.github.hikingc.matrixsdk.api.rooms; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.hikingc.matrixsdk.api.events.content.RoomPowerLevels; +import io.github.hikingc.matrixsdk.api.rooms.queries.CreationRoomType; +import io.github.hikingc.matrixsdk.api.rooms.queries.VisibilityRoomType; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import org.jspecify.annotations.NonNull; + +/// The configuration data that a server will follow to configure the room. +/// +/// @param creationContent extra keys, currently only `m.federate` is mapped. +/// @param initialState a [List] of state events to set in the new room. This allows the user to +/// override the default state events set in the new room. +/// @param invite a [List] of UserIDs to invite to the room. The server will be responsible for +/// handling these invitations, +/// @param invite3pid a [List] of objects representing third-party IDs to invite into the room. +/// @param isDirect Sets a flag on `m.room.member` events. See the +/// [spec](https://spec.matrix.org/v1.18/client-server-api/#direct-messaging) for more +/// information, +/// @param name of the room. Overwrites `initialState`. +/// @param powerLevelContentOverride the power level content to override in the default power level +/// event. This object is applied on top of the generated `m.room.power_levels` event content +/// prior to it being sent to the room. Defaults to overriding nothing. +/// @param preset Convenience parameter for setting various default state events based on a +/// [CreationRoomType] value. If unset, it will use `visibility`. +/// @param roomAliasName if included, a room alias will be created and mapped to the newly created +/// room. The alias will belong on the same homeserver which created the room. +/// @param roomVersion to set for the room. If not provided, the homeserver is to use its configured +/// default. If provided, the homeserver will return a 400 error with the errcode +/// M_UNSUPPORTED_ROOM_VERSION if it does not support the room version. +/// @param topic of the room topic. Overwrites `initialState`. +/// @param visibility of the room. Defaults to private if unset. +@JsonInclude(JsonInclude.Include.NON_ABSENT) +public record InitialRoomConfiguration( + CreationContent creationContent, + List initialState, + List invite, + @JsonProperty("invite_3pid") List invite3pid, + Boolean isDirect, + String name, + RoomPowerLevels powerLevelContentOverride, + CreationRoomType preset, + String roomAliasName, + String roomVersion, + String topic, + VisibilityRoomType visibility) { + /// Extra keys, such as m.federate, to be added to the content of the m.room.create event. + /// + /// @param isFederated If the room will be federated. + public record CreationContent(@JsonProperty("m.federate") Boolean isFederated) {} + + /// A list of state events to set in the new room. This allows the user to override the default + /// state events set in the new room. + /// + /// Takes precedence over events set by preset, but gets overridden by name and topic keys. + /// + /// @param content The content of the event. + /// @param stateKey The state\_key of the state event. Defaults to an empty string. + /// @param type The type of event to send. + public record StateEvent(Object content, String stateKey, String type) {} + + /// Represents third-party IDs to invite to the room. + /// + /// @param address + /// @param idAccessToken + /// @param idServer + /// @param medium + public record Invite3pid(String address, String idAccessToken, String idServer, String medium) {} + + /// Creates a federated, empty and private room with the name and topic desired. + /// + /// @param name of the room. + /// @param topic of the room. + /// @return a private room preset, ready to be used. + @NonNull + public static InitialRoomConfiguration createRoomWithSaneDefaults(String name, String topic) { + Objects.requireNonNull(name, "Room name must not be null"); + Objects.requireNonNull(topic, "Topic must not be null"); + return new InitialRoomConfiguration( + new CreationContent(true), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + false, + name, + null, + CreationRoomType.PRIVATE_CHAT, + null, + null, + topic, + VisibilityRoomType.PRIVATE); + } +} diff --git a/src/main/java/io/github/hikingc/matrixsdk/api/rooms/MatrixRoom.java b/src/main/java/io/github/hikingc/matrixsdk/api/rooms/MatrixRoom.java deleted file mode 100644 index 1ba02a5..0000000 --- a/src/main/java/io/github/hikingc/matrixsdk/api/rooms/MatrixRoom.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.github.hikingc.matrixsdk.api.rooms; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -/// This record represents the configuration that the server will follow to configure the room. Not -/// all possible parameters are implemented but the most essential ones are. -/// -/// @param creationContent Extra keys, currently only m.federate is mapped. -/// @param initialState A list of state events to set in the new room. This allows the user to -/// override the default state events set in the new room. -/// @param userIds An array of user IDs to invite to the room. The server will be responsible for -/// handling these invitations, -/// @param isDirect Sets a flag on m.room.member events. See the -/// [spec](https://spec.matrix.org/v1.18/client-server-api/#direct-messaging) for more -/// information, -/// @param name Sets the name of the room. Overwrites `initialState`. -/// @param preset Convenience parameter for setting various default state events based on a preset. -/// If unset, it will use `visibility`, use [CreationRoomType] to determine which one. -/// @param roomAliasName If this is included, a room alias will be created and mapped to the newly -/// created room. The alias will belong on the same homeserver which created the room. -/// @param topic Sets the name of the room topic. Overwrites `initialState`. -/// @param visibility Defaults to private if unset. -@JsonInclude(JsonInclude.Include.NON_ABSENT) -public record MatrixRoom( - CreationContent creationContent, - StateEvent initialState, - List userIds, - Boolean isDirect, - String name, - String preset, - String roomAliasName, - String topic, - String visibility) { - /// Extra keys, such as m.federate, to be added to the content of the m.room.create event. - /// - /// @param isFederated If the room will be federated. - public record CreationContent(@JsonProperty("m.federate") Boolean isFederated) {} - - /// A list of state events to set in the new room. This allows the user to override the default - /// state events set in the new room. - /// - /// Takes precedence over events set by preset, but gets overridden by name and topic keys. - /// - /// @param content The content of the event. - /// @param stateKey The state\_key of the state event. Defaults to an empty string. - /// @param type The type of event to send. - public record StateEvent(Object content, String stateKey, String type) {} -} diff --git a/src/main/java/io/github/hikingc/matrixsdk/api/rooms/queries/CreationRoomType.java b/src/main/java/io/github/hikingc/matrixsdk/api/rooms/queries/CreationRoomType.java index cc061ca..074d9e7 100644 --- a/src/main/java/io/github/hikingc/matrixsdk/api/rooms/queries/CreationRoomType.java +++ b/src/main/java/io/github/hikingc/matrixsdk/api/rooms/queries/CreationRoomType.java @@ -1,27 +1,18 @@ package io.github.hikingc.matrixsdk.api.rooms.queries; +import com.fasterxml.jackson.annotation.JsonProperty; + /// The room type keys used to tell the client what available preset should the server create the /// room with. public enum CreationRoomType { /// Recommended to use this to configure when you want to make 1 to 1 conversations. - PRIVATE_CHAT("private_chat"), - /// Same as PRIVATE\_CHAT except all invitees are given the same power level as the room creator. - TRUSTED_PRIVATE_CHAT("trusted_private_chat"), + @JsonProperty("private_chat") + PRIVATE_CHAT, + /// Same as [#PRIVATE_CHAT] except all invitees are given the same power level as the room creator. + @JsonProperty("trusted_private_chat") + TRUSTED_PRIVATE_CHAT, /// For public access, unlike the other types, choosing this will forbid guest access. - PUBLIC_CHAT("public_chat"); - - private final String value; - - CreationRoomType(String value) { - this.value = value; - } - - /// Returns the string room type value ('private\_chat', 'public\_chat' or - /// 'trusted\_private\_chat') expected by the Matrix homeserver. - /// - /// @return the parameter string - public String getValue() { - return this.value; - } + @JsonProperty("public_chat") + PUBLIC_CHAT } diff --git a/src/main/java/io/github/hikingc/matrixsdk/api/rooms/queries/VisibilityRoomType.java b/src/main/java/io/github/hikingc/matrixsdk/api/rooms/queries/VisibilityRoomType.java index 34e50d8..7fa7be0 100644 --- a/src/main/java/io/github/hikingc/matrixsdk/api/rooms/queries/VisibilityRoomType.java +++ b/src/main/java/io/github/hikingc/matrixsdk/api/rooms/queries/VisibilityRoomType.java @@ -1,22 +1,13 @@ package io.github.hikingc.matrixsdk.api.rooms.queries; -/// The new visibility type for the room. +import com.fasterxml.jackson.annotation.JsonProperty; + +/// The visibility type for a room. public enum VisibilityRoomType { /// Set the visibility private. - PRIVATE("private"), + @JsonProperty("private") + PRIVATE, /// Set the visibility to public. - PUBLIC("public"); - - private final String value; - - VisibilityRoomType(String value) { - this.value = value; - } - - /// Returns the parameter value ('private' or 'public') expected by Matrix servers. - /// - /// @return the parameter visibility value. - public String getValue() { - return this.value; - } + @JsonProperty("public") + PUBLIC } diff --git a/src/main/java/io/github/hikingc/matrixsdk/services/rooms/RoomService.java b/src/main/java/io/github/hikingc/matrixsdk/services/rooms/RoomService.java index f162203..60645e7 100644 --- a/src/main/java/io/github/hikingc/matrixsdk/services/rooms/RoomService.java +++ b/src/main/java/io/github/hikingc/matrixsdk/services/rooms/RoomService.java @@ -8,7 +8,6 @@ import io.github.hikingc.matrixsdk.api.rooms.*; import io.github.hikingc.matrixsdk.api.rooms.models.ResolvedAlias; import io.github.hikingc.matrixsdk.api.rooms.models.RoomSummary; -import io.github.hikingc.matrixsdk.api.rooms.queries.CreationRoomType; import io.github.hikingc.matrixsdk.api.rooms.queries.JoinRoomRequest; import io.github.hikingc.matrixsdk.api.rooms.queries.VisibilityRoomType; import io.github.hikingc.matrixsdk.context.ClientContext; @@ -53,50 +52,25 @@ public RoomService(ClientContext context) { } @Override - public String create( - boolean isFederated, - String name, - String aliasName, - String topic, - CreationRoomType type, - boolean isVisible) { - - String visibility = isVisible ? "public" : "private"; - - MatrixRoom roomPayload = - new MatrixRoom( - new MatrixRoom.CreationContent(isFederated), - null, - null, - null, - name, - type.getValue(), - aliasName, - topic, - visibility); + public String create(InitialRoomConfiguration configuration) { String jsonPayload; try { - jsonPayload = objectMapper.writeValueAsString(roomPayload); + jsonPayload = objectMapper.writeValueAsString(configuration); } catch (JacksonException e) { throw new MatrixIOException("Failed to parse input data", e); } String responseBody; - try { - responseBody = - httpTransport.postEvent( - URI.create( - context.discoveryResponse().homeserver().baseUrl() - + "/_matrix/client/v3/createRoom"), - jsonPayload, - context.token()); - - return Mapper.getStringValueOfAJsonKey(responseBody, ROOM_ID); + responseBody = + httpTransport.postEvent( + URI.create( + context.discoveryResponse().homeserver().baseUrl() + + "/_matrix/client/v3/createRoom"), + jsonPayload, + context.token()); - } catch (JacksonException e) { - throw new MatrixIOException("Failed to parse Matrix response JSON ", e); - } + return Mapper.getStringValueOfAJsonKey(responseBody, ROOM_ID); } @Override @@ -175,19 +149,20 @@ public List getJoinedRooms() { @Override public void inviteUser(RoomID roomId, RoomMembershipRequest event) { + String serializedInputData; try { - var serializedInputData = objectMapper.writeValueAsString(event); - httpTransport.postEvent( - URI.create( - context.discoveryResponse().homeserver().baseUrl() - + ROOM_ENDPOINT - + roomId - + "/invite"), - serializedInputData, - this.context.token()); + serializedInputData = objectMapper.writeValueAsString(event); } catch (JacksonException e) { - throw new MatrixIOException("Failed to parse Matrix response JSON ", e); + throw new MatrixIOException("Failed to parse input data", e); } + httpTransport.postEvent( + URI.create( + context.discoveryResponse().homeserver().baseUrl() + + ROOM_ENDPOINT + + roomId + + "/invite"), + serializedInputData, + this.context.token()); } @Override @@ -204,13 +179,14 @@ public String joinByRoomIdOrAliasIfAllowed( context.discoveryResponse().homeserver().baseUrl(), "/_matrix/client/v3/join/" + roomIdOrAlias, params); + String serializedInputData; try { - var serializedInputData = objectMapper.writeValueAsString(request); - var responseBody = httpTransport.postEvent(uri, serializedInputData, context.token()); - return Mapper.getStringValueOfAJsonKey(responseBody, ROOM_ID); + serializedInputData = objectMapper.writeValueAsString(request); } catch (JacksonException e) { - throw new MatrixIOException("Failed to parse Matrix response JSON ", e); + throw new MatrixIOException("Failed to parse input data", e); } + var responseBody = httpTransport.postEvent(uri, serializedInputData, context.token()); + return Mapper.getStringValueOfAJsonKey(responseBody, ROOM_ID); } @Override @@ -222,13 +198,14 @@ public String joinByRoomIdIfAllowed(RoomID roomId, JoinRoomRequest request, List context.discoveryResponse().homeserver().baseUrl(), ROOM_ENDPOINT + roomId + "/join", params); + String serializedInputData; try { - var serializedInputData = objectMapper.writeValueAsString(request); - var responseBody = httpTransport.postEvent(uri, serializedInputData, context.token()); - return Mapper.getStringValueOfAJsonKey(responseBody, ROOM_ID); + serializedInputData = objectMapper.writeValueAsString(request); } catch (JacksonException e) { - throw new MatrixIOException("Failed to parse Matrix response JSON ", e); + throw new MatrixIOException("Failed to parse input data", e); } + var responseBody = httpTransport.postEvent(uri, serializedInputData, context.token()); + return Mapper.getStringValueOfAJsonKey(responseBody, ROOM_ID); } @Override @@ -277,70 +254,63 @@ public void leave(RoomID roomId) { @Override public void kick(RoomID roomId, RoomMembershipRequest event) { + String serializedInputData; try { - var serializedInputData = objectMapper.writeValueAsString(event); - httpTransport.postEvent( - URI.create( - context.discoveryResponse().homeserver().baseUrl() - + ROOM_ENDPOINT - + roomId - + "/kick"), - serializedInputData, - this.context.token()); + serializedInputData = objectMapper.writeValueAsString(event); } catch (JacksonException e) { - throw new MatrixIOException("Failed to parse Matrix response JSON ", e); + throw new MatrixIOException("Failed to parse input data", e); } + httpTransport.postEvent( + URI.create( + context.discoveryResponse().homeserver().baseUrl() + ROOM_ENDPOINT + roomId + "/kick"), + serializedInputData, + this.context.token()); } @Override public void ban(RoomID roomId, RoomMembershipRequest event) { + String serializedInputData; try { - var serializedInputData = objectMapper.writeValueAsString(event); - httpTransport.postEvent( - URI.create( - context.discoveryResponse().homeserver().baseUrl() + ROOM_ENDPOINT + roomId + "/ban"), - serializedInputData, - this.context.token()); + serializedInputData = objectMapper.writeValueAsString(event); } catch (JacksonException e) { - throw new MatrixIOException("Failed to parse Matrix response JSON ", e); + throw new MatrixIOException("Failed to parse input data", e); } + httpTransport.postEvent( + URI.create( + context.discoveryResponse().homeserver().baseUrl() + ROOM_ENDPOINT + roomId + "/ban"), + serializedInputData, + this.context.token()); } @Override public void unban(RoomID roomId, RoomMembershipRequest event) { + String responseBody; try { - var responseBody = objectMapper.writeValueAsString(event); - httpTransport.postEvent( - URI.create( - context.discoveryResponse().homeserver().baseUrl() - + ROOM_ENDPOINT - + roomId - + "/unban"), - responseBody, - this.context.token()); + responseBody = objectMapper.writeValueAsString(event); } catch (JacksonException e) { - throw new MatrixIOException("Failed to parse Matrix response JSON ", e); + throw new MatrixIOException("Failed to parse input data", e); } + httpTransport.postEvent( + URI.create( + context.discoveryResponse().homeserver().baseUrl() + ROOM_ENDPOINT + roomId + "/unban"), + responseBody, + this.context.token()); } @Override public String getRoomDirectoryVisibilityType(RoomID roomId) { - try { - var responseBody = - httpTransport.getEvent( - URI.create( - context.discoveryResponse().homeserver().baseUrl() + DIRECTORY_ENDPOINT + roomId), - null); - return Mapper.getStringValueOfAJsonKey(responseBody, "visibility"); - } catch (JacksonException e) { - throw new MatrixIOException("Failed to parse Matrix response JSON ", e); - } + var responseBody = + httpTransport.getEvent( + URI.create( + context.discoveryResponse().homeserver().baseUrl() + DIRECTORY_ENDPOINT + roomId), + null); + return Mapper.getStringValueOfAJsonKey(responseBody, "visibility"); } @Override public void setRoomDirectoryVisibilityType(RoomID roomId, VisibilityRoomType roomType) { Map map = new HashMap<>(); - map.put("visibility", roomType.getValue()); + map.put("visibility", roomType); httpTransport.putEvent( URI.create( diff --git a/src/test/java/io/github/hikingc/matrixsdk/services/rooms/RoomServiceTest.java b/src/test/java/io/github/hikingc/matrixsdk/services/rooms/RoomServiceTest.java index 58b58dd..d0a4762 100644 --- a/src/test/java/io/github/hikingc/matrixsdk/services/rooms/RoomServiceTest.java +++ b/src/test/java/io/github/hikingc/matrixsdk/services/rooms/RoomServiceTest.java @@ -6,6 +6,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; import com.github.tomakehurst.wiremock.junit5.WireMockTest; import io.github.hikingc.matrixsdk.api.MatrixClient; +import io.github.hikingc.matrixsdk.api.events.content.RoomPowerLevels; import io.github.hikingc.matrixsdk.api.identifiers.RoomAlias; import io.github.hikingc.matrixsdk.api.identifiers.RoomID; import io.github.hikingc.matrixsdk.api.identifiers.Validator; @@ -15,6 +16,8 @@ import io.github.hikingc.matrixsdk.api.rooms.queries.VisibilityRoomType; import io.github.hikingc.matrixsdk.context.DiscoveryResponse; import java.util.List; +import java.util.Map; + import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -51,15 +54,60 @@ void sendCreateRequest_WithACorrectPayload_thenReturnARoomId() { .withRequestBody( equalToJson( """ - { - "creation_content": { "m.federate": true }, - "name": "name", - "preset": "public_chat", - "room_alias_name": "alias", - "topic": "topic", - "visibility": "public" - } - """, + { + "visibility": "private", + "room_alias_name": "thepub", + "name": "The Grand Duke Pub", + "topic": "All about happy hour", + "invite": ["@alice:example.com", "@bob:example.com"], + "invite_3pid": [ + { + "id_server": "identity.example.com", + "id_access_token": "abc123_OpaqueString", + "medium": "email", + "address": "alice@example.com" + } + ], + "room_version": "11", + "creation_content": { + "m.federate": false + }, + "initial_state": [ + { + "type": "m.room.join_rules", + "state_key": "", + "content": { + "join_rule": "public" + } + }, + { + "type": "m.room.history_visibility", + "state_key": "", + "content": { + "history_visibility": "shared" + } + } + ], + "preset": "private_chat", + "is_direct": false, + "power_level_content_override": { + "users_default": 0, + "events_default": 0, + "state_default": 50, + "ban": 50, + "kick": 50, + "redact": 50, + "invite": 0, + "events": { + "m.room.name": 50, + "m.room.power_levels": 100 + }, + "users": { + "@alice:example.com": 100 + } + } + } + """, true, true)) .willReturn( @@ -68,10 +116,51 @@ void sendCreateRequest_WithACorrectPayload_thenReturnARoomId() { { "room_id": "%s" } """ .formatted(expectedRoomId)))); - + InitialRoomConfiguration config = new InitialRoomConfiguration( + new InitialRoomConfiguration.CreationContent(false), // m.federate: false + List.of( + new InitialRoomConfiguration.StateEvent( + Map.of("join_rule", "public"), + "", + "m.room.join_rules"), + new InitialRoomConfiguration.StateEvent( + Map.of("history_visibility", "shared"), + "", + "m.room.history_visibility") + ), + List.of("@alice:example.com", "@bob:example.com"), + List.of( + new InitialRoomConfiguration.Invite3pid( + "alice@example.com", + "abc123_OpaqueString", + "identity.example.com", + "email") + ), + false, // is_direct + "The Grand Duke Pub", + new RoomPowerLevels( + 50, // ban + Map.of( + "m.room.name", 50, + "m.room.power_levels", 100 + ), // events + 0, // eventsDefault + 0, // invite + 50, // kick + null, // notifications — not present in source JSON + 50, // redact + 50, // stateDefault + Map.of("@alice:example.com", 100), // users + 0 // users_default + ), + CreationRoomType.PRIVATE_CHAT, + "thepub", + "11", + "All about happy hour", + VisibilityRoomType.PRIVATE + ); var response = - client.room().create(true, "name", "alias", "topic", CreationRoomType.PUBLIC_CHAT, true); - + client.room().create(config); assertEquals(expectedRoomId, response); }