fluffychat merge

This commit is contained in:
ggurdin 2026-02-03 12:04:49 -05:00
commit 5664772dba
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
5 changed files with 37 additions and 5 deletions

View file

@ -44,7 +44,6 @@ import '../../widgets/matrix.dart';
import 'package:fluffychat/utils/tor_stub.dart'
if (dart.library.html) 'package:tor_detector_web/tor_detector_web.dart';
enum PopupMenuAction {
settings,
invite,

View file

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:collection/collection.dart' show IterableExtension;
import 'package:matrix/encryption/utils/key_verification.dart';
import 'package:matrix/matrix.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/pages/device_settings/device_settings_view.dart';
@ -52,6 +53,18 @@ class DevicesSettingsController extends State<DevicesSettings> {
}
void removeDevicesAction(List<Device> devices) async {
final client = Matrix.of(context).client;
final accountManageUrl = client.wellKnown?.additionalProperties
.tryGetMap<String, Object?>('org.matrix.msc2965.authentication')
?.tryGet<String>('account');
if (accountManageUrl != null) {
launchUrlString(
accountManageUrl,
mode: LaunchMode.inAppBrowserView,
);
return;
}
if (await showOkCancelAlertDialog(
context: context,
title: L10n.of(context).areYouSure,

View file

@ -114,8 +114,7 @@ abstract class ClientManager {
return Client(
clientName,
httpClient:
PlatformInfos.isAndroid ? CustomHttpClient.createHTTPClient() : null,
httpClient: CustomHttpClient.createHTTPClient(),
verificationMethods: {
KeyVerificationMethod.numbers,
if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isLinux)

View file

@ -3,9 +3,15 @@ import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:http/io_client.dart';
import 'package:http/retry.dart' as retry;
import 'package:fluffychat/config/isrg_x1.dart';
import 'package:fluffychat/utils/platform_infos.dart';
/// Custom Client to add an additional certificate. This is for the isrg X1
/// certificate which is needed for LetsEncrypt certificates. It is shipped
/// on Android since OS version 7.1. As long as we support older versions we
/// still have to ship this certificate by ourself.
class CustomHttpClient {
static HttpClient customHttpClient(String? cert) {
final context = SecurityContext.defaultContext;
@ -26,5 +32,9 @@ class CustomHttpClient {
return HttpClient(context: context);
}
static http.Client createHTTPClient() => IOClient(customHttpClient(ISRG_X1));
static http.Client createHTTPClient() => retry.RetryClient(
PlatformInfos.isAndroid
? IOClient(customHttpClient(ISRG_X1))
: http.Client(),
);
}

View file

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:matrix/matrix.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
@ -15,6 +16,14 @@ class ErrorReporter {
const ErrorReporter(this.context, [this.message]);
static const Set<Type> ingoredTypes = {
IOException,
http.ClientException,
SocketException,
TlsException,
HandshakeException,
};
Future<File> _getTemporaryErrorLogFile() async {
final tempDir = await getTemporaryDirectory();
return File(path.join(tempDir.path, 'error_log.txt'));
@ -24,6 +33,7 @@ class ErrorReporter {
Object error, [
StackTrace? stackTrace,
]) async {
if (ingoredTypes.contains(error.runtimeType)) return;
final file = await _getTemporaryErrorLogFile();
if (await file.exists()) await file.delete();
await file.writeAsString(
@ -35,14 +45,15 @@ class ErrorReporter {
final file = await _getTemporaryErrorLogFile();
if (!(await file.exists())) return;
final content = await file.readAsString();
// #Pangea
// _onErrorCallback(content);
onErrorCallback(content);
// Pangea#
await file.delete();
}
void onErrorCallback(Object error, [StackTrace? stackTrace]) {
if (ingoredTypes.contains(error.runtimeType)) return;
Logs().e(message ?? 'Error caught', error, stackTrace);
// #Pangea
// final text = '$error\n${stackTrace ?? ''}';