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

View file

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

View file

@ -87,7 +87,8 @@ class Client {
this.enableE2eeRecovery = false,
this.verificationMethods,
http.Client httpClient,
this.importantStateEvents}) {
this.importantStateEvents,
this.pinUnreadRooms = false}) {
verificationMethods ??= <KeyVerificationMethod>{};
importantStateEvents ??= <String>{};
importantStateEvents.addAll([
@ -1101,13 +1102,16 @@ class Client {
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
/// rooms are sorted by timestamp of the last m.room.message event or the last
/// event if there is no known message.
RoomSorter sortRoomsBy = (a, b) => (a.membership != b.membership)
? (a.membership == Membership.invite ? -1 : 1)
: (a.isFavourite != b.isFavourite)
? (a.isFavourite ? -1 : 1)
RoomSorter get sortRoomsBy => (a, b) => (a.isFavourite != b.isFavourite)
? (a.isFavourite ? -1 : 1)
: (pinUnreadRooms && a.notificationCount != b.notificationCount)
? b.notificationCount.compareTo(a.notificationCount)
: b.timeCreated.millisecondsSinceEpoch
.compareTo(a.timeCreated.millisecondsSinceEpoch);

View file

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

View file

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

View file

@ -89,7 +89,13 @@ class Event extends MatrixEvent {
this.roomId = roomId ?? room?.id;
this.senderId = senderId;
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.originServerTs = originServerTs;
}

View file

@ -71,7 +71,10 @@ class User extends Event {
String get id => stateKey;
/// 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.
int get powerLevel => room?.getPowerLevelByUserId(id);
@ -89,9 +92,13 @@ class User extends Event {
}, orElse: () => Membership.join);
/// The avatar if the user has one.
Uri get avatarUrl => content != null && content['avatar_url'] is String
? Uri.parse(content['avatar_url'])
: null;
Uri get avatarUrl => content != null && content.containsKey('avatar_url')
? (content['avatar_url'] is String
? Uri.parse(content['avatar_url'])
: 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
/// has no displayname. If [formatLocalpart] is true, then the localpart will

View file

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

View file

@ -19,16 +19,8 @@ dependencies:
crypto: ^2.1.4
base58check: ^1.0.1
password_hash: ^2.0.0
olm:
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
olm: ^1.2.1
matrix_file_e2ee: ^1.0.4
dev_dependencies:
test: ^1.0.0