From 50765afdc519e9cf2f3ad2a500ac4ed48e3e926c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ku=C3=9Fowski?= Date: Sat, 14 Feb 2026 08:31:57 +0100 Subject: [PATCH] feat: Display state event when user changed their keys --- lib/l10n/intl_en.arb | 21 ++++++++++++++++++- lib/pages/chat/events/state_message.dart | 15 +++++++++++++ lib/utils/client_manager.dart | 3 +++ .../matrix_sdk_extensions/matrix_locals.dart | 5 +++++ pubspec.lock | 9 ++++---- pubspec.yaml | 5 ++++- 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index da89e973f..0641e037d 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -3134,5 +3134,24 @@ "removeAdminRights": "Remove admin rights", "powerLevel": "Power level", "setPowerLevelDescription": "Power levels define what a member is allowed to do in this room and usually range between 0 and 100.", - "owner": "Owner" + "owner": "Owner", + "userHasChangedTheirKeys": "{user} has changed their keys.", + "@userHasChangedTheirKeys": { + "type": "String", + "placeholders": { + "user": { + "type": "String" + } + } + }, + "usersHaveChangedTheirKeys": "{users} have changed their keys.", + "@usersHaveChangedTheirKeys": { + "type": "String", + "placeholders": { + "users": { + "type": "String" + } + } + }, + "check": "Check" } diff --git a/lib/pages/chat/events/state_message.dart b/lib/pages/chat/events/state_message.dart index 9c8ad3da7..775d8fded 100644 --- a/lib/pages/chat/events/state_message.dart +++ b/lib/pages/chat/events/state_message.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:matrix/matrix.dart'; import 'package:fluffychat/config/setting_keys.dart'; @@ -51,6 +52,20 @@ class StateMessage extends StatelessWidget { MatrixLocals(L10n.of(context)), ), ), + if (event.type == EventTypes.TofuNotification) ...[ + const TextSpan(text: ' '), + TextSpan( + text: L10n.of(context).check, + style: TextStyle( + color: theme.colorScheme.primary, + decoration: TextDecoration.underline, + ), + recognizer: TapGestureRecognizer() + ..onTap = () => context.go( + '/rooms/${event.room.id}/encryption', + ), + ), + ], if (onExpand != null) ...[ const TextSpan(text: '\n'), TextSpan( diff --git a/lib/utils/client_manager.dart b/lib/utils/client_manager.dart index 856a907ab..a9e9486f4 100644 --- a/lib/utils/client_manager.dart +++ b/lib/utils/client_manager.dart @@ -111,6 +111,9 @@ abstract class ClientManager { final shareKeysWith = AppSettings.shareKeysWith.value; final enableSoftLogout = AppSettings.enableSoftLogout.value; + EventLocalizations.localizationsMap['sdk.matrix.dart.tofu_event'] = + (event, _, body) => body; + return Client( clientName, httpClient: CustomHttpClient.createHTTPClient(), diff --git a/lib/utils/matrix_sdk_extensions/matrix_locals.dart b/lib/utils/matrix_sdk_extensions/matrix_locals.dart index 9a12d25f7..a31677078 100644 --- a/lib/utils/matrix_sdk_extensions/matrix_locals.dart +++ b/lib/utils/matrix_sdk_extensions/matrix_locals.dart @@ -371,4 +371,9 @@ class MatrixLocals extends MatrixLocalizations { @override String get pollHasBeenEnded => l10n.pollHasBeenEnded; + + @override + String usersHaveChangedTheirKeys(List users) => users.length == 1 + ? l10n.userHasChangedTheirKeys(users.single) + : l10n.usersHaveChangedTheirKeys(users.join(', ')); } diff --git a/pubspec.lock b/pubspec.lock index 3edd5d9e9..e752496d9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1127,10 +1127,11 @@ packages: matrix: dependency: "direct main" description: - name: matrix - sha256: c0214ee99a73957d3c02d54a60afcf9acee577b0924749085d6fdf556e8eba42 - url: "https://pub.dev" - source: hosted + path: "." + ref: "krille/tofu-for-master-signing-keys" + resolved-ref: "1889d3020e757cfacc1de28d81f62ab83119a6b5" + url: "https://github.com/famedly/matrix-dart-sdk.git" + source: git version: "6.1.1" meta: dependency: transitive diff --git a/pubspec.yaml b/pubspec.yaml index d3ebae0c9..0596eb11a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,7 +53,10 @@ dependencies: just_audio: ^0.10.5 latlong2: ^0.9.1 linkify: ^5.0.0 - matrix: ^6.1.1 + matrix: #^6.1.1 + git: + url: https://github.com/famedly/matrix-dart-sdk.git + ref: krille/tofu-for-master-signing-keys mime: ^2.0.0 native_imaging: ^0.4.0 opus_caf_converter_dart: ^1.0.1