Skip to content

Commit

Permalink
feat: Send state event to timeline on creating new megolm session
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Feb 3, 2025
1 parent 0960e35 commit c99449d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/encryption/key_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ class KeyManager {
sess.outboundGroupSession!.session_id(),
);
if (inboundSess == null) {
Logs().e(
'No inbound session found for outbound group session!',
sess.outboundGroupSession?.session_id(),
);
wipe = true;
}

Expand Down Expand Up @@ -601,6 +605,27 @@ class KeyManager {
);
await storeOutboundGroupSession(roomId, sess);
_outboundGroupSessions[roomId] = sess;
final devices = deviceKeys.map((keys) => keys.deviceId).toList();
final users = deviceKeys.fold(
<String>{},
(users, keys) => users..add(keys.userId),
).toList();
client.onTimelineEvent.add(
Event(
eventId: 'fake_event_${rawSession['session_id']}',
content: {
'body':
'🔒 Verschlüsselte Unterhaltung von ${users.length} Benutzern mit ${devices.length} Geräten',
'devices': devices,
'members': users,
},
type: 'sdk.dart.matrix.new_megolm_session',
senderId: client.userID!,
originServerTs: DateTime.now(),
room: room,
stateKey: '',
),
);
} catch (e, s) {
Logs().e(
'[LibOlm] Unable to send the session key to the participating devices',
Expand Down
1 change: 1 addition & 0 deletions lib/src/utils/event_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ abstract class EventLocalizations {
EventTypes.Sticker: (event, i18n, body) => i18n.sentASticker(
event.senderFromMemoryOrFallback.calcDisplayname(i18n: i18n),
),
'sdk.dart.matrix.new_megolm_session': (event, i18n, body) => body,
EventTypes.Redaction: (event, i18n, body) => i18n.redactedAnEvent(event),
EventTypes.RoomAliases: (event, i18n, body) => i18n.changedTheRoomAliases(
event.senderFromMemoryOrFallback.calcDisplayname(i18n: i18n),
Expand Down

0 comments on commit c99449d

Please sign in to comment.