Merge branch 'krille/create-chat-commands' into 'main'
feat: Add commands to create chats See merge request famedly/company/frontend/famedlysdk!903
This commit is contained in:
		
						commit
						ffb4540172
					
				|  | @ -98,6 +98,19 @@ extension CommandsClientExtension on Client { | ||||||
|         txid: args.txid, |         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 { |     addCommand('plain', (CommandArgs args) async { | ||||||
|       return await args.room.sendTextEvent( |       return await args.room.sendTextEvent( | ||||||
|         args.msg, |         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 { |     test('discardsession', () async { | ||||||
|       if (olmEnabled) { |       if (olmEnabled) { | ||||||
|         await client.encryption?.keyManager.createOutboundGroupSession(room.id); |         await client.encryption?.keyManager.createOutboundGroupSession(room.id); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue