diff --git a/lib/src/Client.dart b/lib/src/Client.dart index b87a4aa..6e32afd 100644 --- a/lib/src/Client.dart +++ b/lib/src/Client.dart @@ -297,16 +297,26 @@ class Client { return contacts; } + @Deprecated('Please use [createRoom] instead!') + Future createGroup(List users) => createRoom(invite: users); + /// Creates a new group chat and invites the given Users and returns the new - /// created room ID. - Future createGroup(List users) async { + /// created room ID. If [params] are provided, invite will be ignored. For the + /// moment please look at https://matrix.org/docs/spec/client_server/r0.5.0#post-matrix-client-r0-createroom + /// to configure [params]. + Future createRoom( + {List invite, Map params}) async { List inviteIDs = []; - for (int i = 0; i < users.length; i++) inviteIDs.add(users[i].id); + for (int i = 0; i < invite.length; i++) inviteIDs.add(invite[i].id); final dynamic resp = await connection.jsonRequest( type: HTTPType.POST, action: "/client/r0/createRoom", - data: {"invite": inviteIDs, "preset": "private_chat"}); + data: params == null + ? { + "invite": inviteIDs, + } + : params); if (resp is ErrorResponse) { connection.onError.add(resp); diff --git a/test/Client_test.dart b/test/Client_test.dart index b8b87ce..e084bf1 100644 --- a/test/Client_test.dart +++ b/test/Client_test.dart @@ -262,12 +262,12 @@ void main() { expect(loginResp, true); }); - test('createGroup', () async { + test('createRoom', () async { final List users = [ User("@alice:fakeServer.notExisting"), User("@bob:fakeServer.notExisting") ]; - final String newID = await matrix.createGroup(users); + final String newID = await matrix.createRoom(invite: users); expect(newID, "!1234:fakeServer.notExisting"); });