Merge pull request #1888 from famedly/krille/add-m-federate-support

feat: Add support for isFederate option for rooms
This commit is contained in:
Krille-chan 2024-07-26 14:23:38 +02:00 committed by GitHub
commit 87ce08d394
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

View File

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

View File

@ -1347,6 +1347,10 @@ class Room {
@Deprecated('Use fullyRead marker') @Deprecated('Use fullyRead marker')
String? get userFullyReadMarker => fullyRead; 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 /// Sets the position of the read marker for a given room, and optionally the
/// read receipt's location. /// 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. /// 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); 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 { test('getUserByMXID', () async {
final List<String> called = []; final List<String> called = [];
final List<String> called2 = []; final List<String> called2 = [];