Merge branch 'master' into soru/fix-members-requests

This commit is contained in:
Sorunome 2020-07-20 11:53:55 +02:00
commit 0ece2717e0
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C
10 changed files with 60 additions and 57 deletions

6
build.yaml Normal file
View file

@ -0,0 +1,6 @@
targets:
$default:
builders:
moor_generator:
options:
generate_connect_constructor: true

View file

@ -194,8 +194,14 @@ class KeyVerification {
} }
} }
bool _handlePayloadLock = false;
Future<void> handlePayload(String type, Map<String, dynamic> payload, Future<void> handlePayload(String type, Map<String, dynamic> payload,
[String eventId]) async { [String eventId]) async {
while (_handlePayloadLock) {
await Future.delayed(Duration(milliseconds: 50));
}
_handlePayloadLock = true;
print('[Key Verification] Received type ${type}: ' + payload.toString()); print('[Key Verification] Received type ${type}: ' + payload.toString());
try { try {
var thisLastStep = lastStep; var thisLastStep = lastStep;
@ -307,6 +313,8 @@ class KeyVerification {
if (deviceId != null) { if (deviceId != null) {
await cancel('m.invalid_message'); await cancel('m.invalid_message');
} }
} finally {
_handlePayloadLock = false;
} }
} }
@ -529,8 +537,8 @@ class KeyVerification {
Future<void> send(String type, Map<String, dynamic> payload) async { Future<void> send(String type, Map<String, dynamic> payload) async {
makePayload(payload); makePayload(payload);
print('[Key Verification] Sending type ${type}: ' + payload.toString()); print('[Key Verification] Sending type ${type}: ' + payload.toString());
print('[Key Verification] Sending to ${userId} device ${deviceId}');
if (room != null) { if (room != null) {
print('[Key Verification] Sending to ${userId} in room ${room.id}');
if (['m.key.verification.request'].contains(type)) { if (['m.key.verification.request'].contains(type)) {
payload['msgtype'] = type; payload['msgtype'] = type;
payload['to'] = userId; payload['to'] = userId;
@ -544,6 +552,7 @@ class KeyVerification {
encryption.keyVerificationManager.addRequest(this); encryption.keyVerificationManager.addRequest(this);
} }
} else { } else {
print('[Key Verification] Sending to ${userId} device ${deviceId}');
await client.sendToDevice( await client.sendToDevice(
[client.userDeviceKeys[userId].deviceKeys[deviceId]], type, payload); [client.userDeviceKeys[userId].deviceKeys[deviceId]], type, payload);
} }

View file

@ -74,7 +74,9 @@ class PusherData {
}); });
PusherData.fromJson(Map<String, dynamic> json) { PusherData.fromJson(Map<String, dynamic> json) {
if (json.containsKey('url')) {
url = Uri.parse(json['url']); url = Uri.parse(json['url']);
}
format = json['format']; format = json['format'];
} }

View file

@ -87,7 +87,8 @@ class Client {
this.enableE2eeRecovery = false, this.enableE2eeRecovery = false,
this.verificationMethods, this.verificationMethods,
http.Client httpClient, http.Client httpClient,
this.importantStateEvents}) { this.importantStateEvents,
this.pinUnreadRooms = false}) {
verificationMethods ??= <KeyVerificationMethod>{}; verificationMethods ??= <KeyVerificationMethod>{};
importantStateEvents ??= <String>{}; importantStateEvents ??= <String>{};
importantStateEvents.addAll([ importantStateEvents.addAll([
@ -1101,13 +1102,16 @@ class Client {
bool _sortLock = false; bool _sortLock = false;
/// If [true] then unread rooms are pinned at the top of the room list.
bool pinUnreadRooms;
/// The compare function how the rooms should be sorted internally. By default /// The compare function how the rooms should be sorted internally. By default
/// rooms are sorted by timestamp of the last m.room.message event or the last /// rooms are sorted by timestamp of the last m.room.message event or the last
/// event if there is no known message. /// event if there is no known message.
RoomSorter sortRoomsBy = (a, b) => (a.membership != b.membership) RoomSorter get sortRoomsBy => (a, b) => (a.isFavourite != b.isFavourite)
? (a.membership == Membership.invite ? -1 : 1)
: (a.isFavourite != b.isFavourite)
? (a.isFavourite ? -1 : 1) ? (a.isFavourite ? -1 : 1)
: (pinUnreadRooms && a.notificationCount != b.notificationCount)
? b.notificationCount.compareTo(a.notificationCount)
: b.timeCreated.millisecondsSinceEpoch : b.timeCreated.millisecondsSinceEpoch
.compareTo(a.timeCreated.millisecondsSinceEpoch); .compareTo(a.timeCreated.millisecondsSinceEpoch);

View file

@ -15,6 +15,8 @@ part 'database.g.dart';
class Database extends _$Database { class Database extends _$Database {
Database(QueryExecutor e) : super(e); Database(QueryExecutor e) : super(e);
Database.connect(DatabaseConnection connection) : super.connect(connection);
@override @override
int get schemaVersion => 5; int get schemaVersion => 5;
@ -48,7 +50,6 @@ class Database extends _$Database {
} }
if (from == 3) { if (from == 3) {
await m.createTable(userCrossSigningKeys); await m.createTable(userCrossSigningKeys);
await m.createIndex(userCrossSigningKeysIndex);
await m.createTable(ssssCache); await m.createTable(ssssCache);
// mark all keys as outdated so that the cross signing keys will be fetched // mark all keys as outdated so that the cross signing keys will be fetched
await m.issueCustomQuery( await m.issueCustomQuery(

View file

@ -5361,6 +5361,7 @@ class Files extends Table with TableInfo<Files, DbFile> {
abstract class _$Database extends GeneratedDatabase { abstract class _$Database extends GeneratedDatabase {
_$Database(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e); _$Database(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e);
_$Database.connect(DatabaseConnection c) : super.connect(c);
Clients _clients; Clients _clients;
Clients get clients => _clients ??= Clients(this); Clients get clients => _clients ??= Clients(this);
UserDeviceKeys _userDeviceKeys; UserDeviceKeys _userDeviceKeys;

View file

@ -89,7 +89,13 @@ class Event extends MatrixEvent {
this.roomId = roomId ?? room?.id; this.roomId = roomId ?? room?.id;
this.senderId = senderId; this.senderId = senderId;
this.unsigned = unsigned; this.unsigned = unsigned;
this.prevContent = prevContent; // synapse unfortunatley isn't following the spec and tosses the prev_content
// into the unsigned block
this.prevContent = prevContent != null && prevContent.isNotEmpty
? prevContent
: (unsigned != null && unsigned['prev_content'] is Map
? unsigned['prev_content']
: null);
this.stateKey = stateKey; this.stateKey = stateKey;
this.originServerTs = originServerTs; this.originServerTs = originServerTs;
} }

View file

@ -71,7 +71,10 @@ class User extends Event {
String get id => stateKey; String get id => stateKey;
/// The displayname of the user if the user has set one. /// The displayname of the user if the user has set one.
String get displayName => content != null ? content['displayname'] : null; String get displayName =>
content != null && content.containsKey('displayname')
? content['displayname']
: (prevContent != null ? prevContent['displayname'] : null);
/// Returns the power level of this user. /// Returns the power level of this user.
int get powerLevel => room?.getPowerLevelByUserId(id); int get powerLevel => room?.getPowerLevelByUserId(id);
@ -89,9 +92,13 @@ class User extends Event {
}, orElse: () => Membership.join); }, orElse: () => Membership.join);
/// The avatar if the user has one. /// The avatar if the user has one.
Uri get avatarUrl => content != null && content['avatar_url'] is String Uri get avatarUrl => content != null && content.containsKey('avatar_url')
? (content['avatar_url'] is String
? Uri.parse(content['avatar_url']) ? Uri.parse(content['avatar_url'])
: null; : null)
: (prevContent != null && prevContent['avatar_url'] is String
? Uri.parse(prevContent['avatar_url'])
: null);
/// Returns the displayname or the local part of the Matrix ID if the user /// Returns the displayname or the local part of the Matrix ID if the user
/// has no displayname. If [formatLocalpart] is true, then the localpart will /// has no displayname. If [formatLocalpart] is true, then the localpart will

View file

@ -22,13 +22,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.2" version: "0.2.2"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args: args:
dependency: transitive dependency: transitive
description: description:
@ -326,12 +319,10 @@ packages:
matrix_file_e2ee: matrix_file_e2ee:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." name: matrix_file_e2ee
ref: "1.x.y" url: "https://pub.dartlang.org"
resolved-ref: "32edeff765369a7a77a0822f4b19302ca24a017b" source: hosted
url: "https://gitlab.com/famedly/libraries/matrix_file_e2ee.git" version: "1.0.4"
source: git
version: "1.0.3"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -340,7 +331,7 @@ packages:
source: hosted source: hosted
version: "1.1.8" version: "1.1.8"
mime: mime:
dependency: transitive dependency: "direct main"
description: description:
name: mime name: mime
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
@ -398,12 +389,10 @@ packages:
olm: olm:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." name: olm
ref: "1.x.y" url: "https://pub.dartlang.org"
resolved-ref: "8e4fcccff7a2d4d0bd5142964db092bf45061905" source: hosted
url: "https://gitlab.com/famedly/libraries/dart-olm.git" version: "1.2.1"
source: git
version: "1.2.0"
package_config: package_config:
dependency: transitive dependency: transitive
description: description:
@ -432,13 +421,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.0" version: "1.9.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
pointycastle: pointycastle:
dependency: transitive dependency: transitive
description: description:
@ -670,13 +652,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.5.4" version: "0.5.4"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.7.0"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:

View file

@ -19,16 +19,8 @@ dependencies:
crypto: ^2.1.4 crypto: ^2.1.4
base58check: ^1.0.1 base58check: ^1.0.1
password_hash: ^2.0.0 password_hash: ^2.0.0
olm: ^1.2.1
olm: matrix_file_e2ee: ^1.0.4
git:
url: https://gitlab.com/famedly/libraries/dart-olm.git
ref: 1.x.y
matrix_file_e2ee:
git:
url: https://gitlab.com/famedly/libraries/matrix_file_e2ee.git
ref: 1.x.y
dev_dependencies: dev_dependencies:
test: ^1.0.0 test: ^1.0.0