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