Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions commet/lib/client/matrix/matrix_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ class MatrixClient extends Client {
@override
Future<Room> createRoom(CreateRoomArgs args) async {
var creationContent = null;
Map<String, Object?>? powerLevelAdditions = {};

List<matrix.StateEvent>? initialState;
if (args.roomType == RoomType.photoAlbum) {
Expand All @@ -430,6 +431,12 @@ class MatrixClient extends Client {

if (args.roomType == RoomType.voipRoom) {
creationContent = {"type": "org.matrix.msc3417.call"};
powerLevelAdditions = {
"events": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in a room which doesn't follow the default permissions for other types of events as defined by the homeserver.

For example, on my homeserver the default permissions:

        "events": {
          "m.room.avatar": 50,
          "m.room.canonical_alias": 50,
          "m.room.encryption": 100,
          "m.room.history_visibility": 100,
          "m.room.name": 50,
          "m.room.power_levels": 100,
          "m.room.server_acl": 100,
          "m.room.tombstone": 100
        },

but with this change, its only

        "events": {
          "org.matrix.msc3401.call": 0,
          "org.matrix.msc3401.call.member": 0
        },

Maybe it would be better to create the room with default permissions, and then update them to include the call states afterwards?

Copy link
Contributor Author

@jonathanmajh jonathanmajh Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's weird since based on my reading of [powerLevelContentOverride] The power level content to override in the default power level event. This object is applied on top of the generated [m.room.power_levels] event content prior to it being sent to the room. Defaults to overriding nothing. i was thinking it only changes what is included in the override,

But it seems like there is some confusion about this anyways
matrix-org/matrix-spec#492

So i'll change it to a separate call later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok can you check again?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed to be unreliable getting the permission state here, as matrixRoom.getState only gets states which have already been synced, so i changed it to always fetch state from the homeserver

"org.matrix.msc3401.call": 0,
"org.matrix.msc3401.call.member": 0
}
};
}

if (args.roomType == RoomType.calendar) {
Expand Down Expand Up @@ -481,6 +488,26 @@ class MatrixClient extends Client {
await matrixRoom.enableEncryption();
}

if (powerLevelAdditions.isNotEmpty) {
var events = await matrixClient.getRoomState(id);

var currentPerms = events
.firstWhereOrNull((i) => i.type == matrix.EventTypes.RoomPowerLevels)
?.content;

if (currentPerms != null) {
var newPerms = <String, dynamic>{
...currentPerms,
"events": <String, dynamic>{
...?currentPerms["events"] as Map<String, dynamic>?,
...?powerLevelAdditions["events"] as Map<String, dynamic>?,
}
};
_matrixClient.setRoomStateWithKey(
id, matrix.EventTypes.RoomPowerLevels, "", newPerms);
}
}

if (hasRoom(id)) return getRoom(id)!;
var room = MatrixRoom(this, matrixRoom, _matrixClient);
rooms.add(room);
Expand Down
6 changes: 6 additions & 0 deletions commet/lib/ui/organisms/voip_room_view/voip_room_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class _VoipRoomViewState extends State<VoipRoomView> {
var color = Theme.of(context).colorScheme.surfaceContainer;

if (currentSession == null) return unjoinedView(color);
if (currentSession?.state == VoipState.ended) {
setState(() {
joining = false;
});
return unjoinedView(color);
}

return CallWidget(currentSession!);
}
Expand Down