Merge branch 'contactlist-enhance-requestbyroom' into 'master'
[Contactlist] Better contact handling See merge request famedly/famedlysdk!54
This commit is contained in:
commit
20a189ecd8
|
@ -219,6 +219,17 @@ class Client {
|
|||
type: HTTPType.POST, action: "/client/r0/join/$id");
|
||||
}
|
||||
|
||||
/// Loads the contact list for this user excluding 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() 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 {
|
||||
|
|
|
@ -53,7 +53,7 @@ class Connection {
|
|||
String get _syncFilters => '{"room":{"state":{"lazy_load_members":true}}}';
|
||||
|
||||
String get _firstSyncFilters =>
|
||||
'{"room":{"include_leave":true,"state":{"lazy_load_members":false}}}';
|
||||
'{"room":{"include_leave":true,"state":{"lazy_load_members":true}}}';
|
||||
|
||||
/// Handles the connection to the Matrix Homeserver. You can change this to a
|
||||
/// MockClient for testing.
|
||||
|
|
|
@ -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 = "";
|
||||
|
@ -592,7 +601,8 @@ class Store {
|
|||
/// the user [userID]. Returns null if there is none.
|
||||
Future<String> getDirectChatRoomID(String userID) async {
|
||||
List<Map<String, dynamic>> res = await db.rawQuery(
|
||||
"SELECT id FROM Rooms WHERE direct_chat_matrix_id=?", [userID]);
|
||||
"SELECT id FROM Rooms WHERE direct_chat_matrix_id=? AND membership!='leave' LIMIT 1",
|
||||
[userID]);
|
||||
if (res.length != 1) return null;
|
||||
return res[0]["id"];
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ packages:
|
|||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
version: "1.0.4"
|
||||
build:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -297,7 +297,7 @@ packages:
|
|||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0+1"
|
||||
version: "1.7.0"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -309,7 +309,7 @@ class FakeMatrixApi extends MockClient {
|
|||
]
|
||||
}
|
||||
},
|
||||
"/client/r0/sync?filter=%7B%22room%22:%7B%22include_leave%22:true,%22state%22:%7B%22lazy_load_members%22:false%7D%7D%7D":
|
||||
"/client/r0/sync?filter=%7B%22room%22:%7B%22include_leave%22:true,%22state%22:%7B%22lazy_load_members%22:true%7D%7D%7D":
|
||||
(var req) => {
|
||||
"next_batch": Random().nextDouble().toString(),
|
||||
"presence": {
|
||||
|
|
Loading…
Reference in a new issue