feat: Add commands to create chats
This commit is contained in:
parent
5c12a21e2e
commit
a61e1ae4a3
|
|
@ -98,6 +98,19 @@ extension CommandsClientExtension on Client {
|
|||
txid: args.txid,
|
||||
);
|
||||
});
|
||||
addCommand('dm', (CommandArgs args) async {
|
||||
final parts = args.msg.split(' ');
|
||||
return await args.room.client.startDirectChat(
|
||||
parts.first,
|
||||
enableEncryption: !parts.any((part) => part == '--no-encryption'),
|
||||
);
|
||||
});
|
||||
addCommand('create', (CommandArgs args) async {
|
||||
final parts = args.msg.split(' ');
|
||||
return await args.room.client.createGroupChat(
|
||||
enableEncryption: !parts.any((part) => part == '--no-encryption'),
|
||||
);
|
||||
});
|
||||
addCommand('plain', (CommandArgs args) async {
|
||||
return await args.room.sendTextEvent(
|
||||
args.msg,
|
||||
|
|
|
|||
|
|
@ -274,6 +274,28 @@ void main() {
|
|||
});
|
||||
});
|
||||
|
||||
test('dm', () async {
|
||||
FakeMatrixApi.calledEndpoints.clear();
|
||||
await room.sendTextEvent('/dm @alice:example.com --no-encryption');
|
||||
expect(
|
||||
json.decode(
|
||||
FakeMatrixApi.calledEndpoints['/client/r0/createRoom']?.first),
|
||||
{
|
||||
'invite': ['@alice:example.com'],
|
||||
'is_direct': true,
|
||||
'preset': 'trusted_private_chat'
|
||||
});
|
||||
});
|
||||
|
||||
test('create', () async {
|
||||
FakeMatrixApi.calledEndpoints.clear();
|
||||
await room.sendTextEvent('/create @alice:example.com --no-encryption');
|
||||
expect(
|
||||
json.decode(
|
||||
FakeMatrixApi.calledEndpoints['/client/r0/createRoom']?.first),
|
||||
{'preset': 'private_chat'});
|
||||
});
|
||||
|
||||
test('discardsession', () async {
|
||||
if (olmEnabled) {
|
||||
await client.encryption?.keyManager.createOutboundGroupSession(room.id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue