[ContactList] Add functions
This commit is contained in:
parent
a2abb87a79
commit
c95f4acecd
|
@ -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<List<User>> loadFamedlyContacts({String exceptRoomID = ""}) async {
|
||||
Room contactDiscoveryRoom = await store
|
||||
.getRoomByAlias("#famedlyContactDiscovery:${userID.split(":")[1]}");
|
||||
List<User> contacts = await contactDiscoveryRoom.requestParticipants();
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
/// Creates a new group chat and invites the given Users and returns the new
|
||||
/// created room ID.
|
||||
Future<String> createGroup(List<User> users) async {
|
||||
|
|
|
@ -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<List<User>> loadContacts({String exceptRoomID = ""}) async {
|
||||
List<Map<String, dynamic>> 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<Room> getRoomByAlias(String alias) async {
|
||||
List<Map<String, dynamic>> 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<String> getAvatarFromSingleChat(String roomID) async {
|
||||
String avatarStr = "";
|
||||
|
|
Loading…
Reference in a new issue