feat: Add /discardsession command
This commit is contained in:
parent
0611ea1495
commit
6f0c7c5f64
|
|
@ -190,6 +190,11 @@ extension CommandsClientExtension on Client {
|
|||
currentEventJson,
|
||||
);
|
||||
});
|
||||
addCommand('discardsession', (CommandArgs args) async {
|
||||
await encryption?.keyManager
|
||||
?.clearOrUseOutboundGroupSession(args.room.id, wipe: true);
|
||||
return '';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'fake_client.dart';
|
||||
import 'fake_matrix_api.dart';
|
||||
|
|
@ -28,6 +29,7 @@ void main() {
|
|||
group('Commands', () {
|
||||
Client client;
|
||||
Room room;
|
||||
var olmEnabled = true;
|
||||
|
||||
final getLastMessagePayload =
|
||||
([String type = 'm.room.message', String stateKey]) {
|
||||
|
|
@ -40,6 +42,12 @@ void main() {
|
|||
};
|
||||
|
||||
test('setupClient', () async {
|
||||
try {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
} catch (e) {
|
||||
olmEnabled = false;
|
||||
}
|
||||
client = await getClient();
|
||||
room = Room(id: '!1234:fakeServer.notExisting', client: client);
|
||||
room.setState(Event(
|
||||
|
|
@ -249,6 +257,21 @@ void main() {
|
|||
});
|
||||
});
|
||||
|
||||
test('discardsession', () async {
|
||||
if (olmEnabled) {
|
||||
await client.encryption.keyManager.createOutboundGroupSession(room.id);
|
||||
expect(
|
||||
client.encryption.keyManager.getOutboundGroupSession(room.id) !=
|
||||
null,
|
||||
true);
|
||||
await room.sendTextEvent('/discardsession');
|
||||
expect(
|
||||
client.encryption.keyManager.getOutboundGroupSession(room.id) !=
|
||||
null,
|
||||
false);
|
||||
}
|
||||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
await client.dispose(closeDatabase: true);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue