feat: Add support for isFederate option for rooms

This commit is contained in:
Krille 2024-07-26 13:45:13 +02:00
parent c464032855
commit b962e8288b
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
3 changed files with 19 additions and 0 deletions

View File

@ -790,6 +790,7 @@ class Client extends MatrixApi {
HistoryVisibility? historyVisibility,
bool waitForSync = true,
bool groupCall = false,
bool federated = true,
Map<String, dynamic>? powerLevelContentOverride,
}) async {
enableEncryption ??=
@ -824,6 +825,7 @@ class Client extends MatrixApi {
}
final roomId = await createRoom(
creationContent: federated ? null : {'m.federate': false},
invite: invite,
preset: preset,
name: groupName,

View File

@ -1347,6 +1347,10 @@ class Room {
@Deprecated('Use fullyRead marker')
String? get userFullyReadMarker => fullyRead;
bool get isFederated =>
getState(EventTypes.RoomCreate)?.content.tryGet<bool>('m.federate') ??
true;
/// Sets the position of the read marker for a given room, and optionally the
/// read receipt's location.
/// If you set `public` to false, only a private receipt will be sent. A private receipt is always sent if `mRead` is set. If no value is provided, the default from the `client` is used.

View File

@ -778,6 +778,19 @@ void main() {
expect(timeline.events.length, 17);
});
test('isFederated', () {
expect(room.isFederated, true);
room.setState(
StrippedStateEvent(
type: EventTypes.RoomCreate,
content: {'m.federate': false},
senderId: room.client.userID!,
stateKey: '',
),
);
expect(room.isFederated, false);
});
test('getUserByMXID', () async {
final List<String> called = [];
final List<String> called2 = [];