diff --git a/lib/src/Client.dart b/lib/src/Client.dart index 9698c46..d505f1a 100644 --- a/lib/src/Client.dart +++ b/lib/src/Client.dart @@ -219,6 +219,18 @@ class Client { type: HTTPType.POST, action: "/client/r0/join/$id"); } + /// Loads the contact list for this user excluding the users in + /// the given room of id [exceptRoomID] and the user itself. Currently the contacts are + /// found by discovering the contacts of the famedlyContactDiscovery room, which is + /// defined by the autojoin room feature in Synapse. + Future> loadFamedlyContacts({String exceptRoomID = ""}) async { + Room contactDiscoveryRoom = await store + .getRoomByAlias("#famedlyContactDiscovery:${userID.split(":")[1]}"); + List contacts = await contactDiscoveryRoom.requestParticipants(); + + return contacts; + } + /// Creates a new group chat and invites the given Users and returns the new /// created room ID. Future createGroup(List users) async { diff --git a/lib/src/Store.dart b/lib/src/Store.dart index df628a6..1ddbd86 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -458,6 +458,7 @@ class Store { /// Loads all Users in the database to provide a contact list /// except users who are in the Room with the ID [exceptRoomID]. + @deprecated Future> loadContacts({String exceptRoomID = ""}) async { List> res = await db.rawQuery( "SELECT * FROM Users WHERE matrix_id!=? AND chat_id!=? GROUP BY matrix_id ORDER BY displayname", @@ -549,6 +550,14 @@ class Store { return Room.getRoomFromTableRow(res[0], client); } + /// Returns a room without events and participants. + Future getRoomByAlias(String alias) async { + List> res = await db + .rawQuery("SELECT * FROM Rooms WHERE canonical_alias=?", [alias]); + if (res.length != 1) return null; + return Room.getRoomFromTableRow(res[0], client); + } + /// Calculates and returns an avatar for a direct chat by a given [roomID]. Future getAvatarFromSingleChat(String roomID) async { String avatarStr = "";