diff --git a/lib/helpers/ipfs_upload_helper.dart b/lib/helpers/ipfs_upload_helper.dart new file mode 100644 index 00000000..8d294568 --- /dev/null +++ b/lib/helpers/ipfs_upload_helper.dart @@ -0,0 +1,187 @@ +import 'dart:convert'; + +import 'package:flutter/foundation.dart'; +import 'package:http/http.dart' as http; + +import '../models/app_settings.dart'; + +class IpfsUploadHelper { + static http.Client? httpClient; + + static String mimeTypeForFileName(String fileName) { + switch (fileName.toLowerCase().split('.').last) { + case 'jpg': + case 'jpeg': + return 'image/jpeg'; + case 'png': + return 'image/png'; + case 'gif': + return 'image/gif'; + case 'webp': + return 'image/webp'; + case 'heic': + return 'image/heic'; + default: + return 'application/octet-stream'; + } + } + + static Future uploadImageWithSettings({ + required AppSettings settings, + required Uint8List bytes, + required String fileName, + required String mimeType, + }) { + return uploadImage( + bytes: bytes, + fileName: fileName, + mimeType: mimeType, + uploadEndpoint: settings.uploadIpfsEndpoint, + uploadApiKey: settings.uploadIpfsApiKey, + uploadGateway: settings.uploadIpfsGateway, + ); + } + + static Future uploadImage({ + required Uint8List bytes, + required String fileName, + required String mimeType, + required String uploadEndpoint, + required String uploadApiKey, + String uploadGateway = '', + }) async { + final endpoint = uploadEndpoint.trim(); + if (endpoint.isEmpty) { + throw ArgumentError('Configure an IPFS upload endpoint first.'); + } + + final token = uploadApiKey.trim(); + final endpointUri = Uri.parse(endpoint); + final endpointHost = endpointUri.host.toLowerCase(); + final isPinata = + endpointHost.contains('pinata') || + endpoint.toLowerCase().contains('pinfiletoipfs'); + final isFilebase = endpointHost.contains('filebase'); + final isKubo = !isPinata && !isFilebase; + final safeFileName = _sanitizeUploadFileName(fileName); + if (isFilebase && token.isEmpty) { + throw ArgumentError('Filebase RPC requires an API token.'); + } + + final Uri uploadUri; + final request = http.MultipartRequest('POST', endpointUri) + ..files.add( + http.MultipartFile.fromBytes('file', bytes, filename: safeFileName), + ); + + if (isPinata) { + if (token.isEmpty) { + throw ArgumentError('Pinata requires an API key or JWT.'); + } + request.headers['Authorization'] = 'Bearer $token'; + request.fields['pinataOptions'] = jsonEncode({'cidVersion': 1}); + request.fields['pinataMetadata'] = jsonEncode({'name': safeFileName}); + uploadUri = endpointUri; + } else { + final parameters = {'cid-version': '1'}; + if (isKubo) parameters['pin'] = 'true'; + uploadUri = endpointUri.replace( + queryParameters: {...endpointUri.queryParameters, ...parameters}, + ); + if (token.isNotEmpty) { + request.headers['Authorization'] = 'Bearer $token'; + } + } + + final finalRequest = request.url == uploadUri + ? request + : (http.MultipartRequest('POST', uploadUri) + ..headers.addAll(request.headers) + ..fields.addAll(request.fields) + ..files.addAll(request.files)); + final client = httpClient; + final response = await (client == null + ? finalRequest.send() + : client.send(finalRequest)); + final body = await response.stream.bytesToString(); + if (response.statusCode < 200 || response.statusCode >= 300) { + throw Exception('IPFS upload failed (${response.statusCode}): $body'); + } + + final cid = _extractUploadCid(body, isPinata: isPinata); + if (cid == null || cid.isEmpty) { + throw Exception('IPFS upload did not return a CID.'); + } + + if (isKubo) { + await _copyKuboFileToMfs( + endpoint: endpoint, + cid: cid, + fileName: safeFileName, + authorization: token.isEmpty ? null : 'Bearer $token', + ); + } + + final gateway = normalizeIpfsGateway(uploadGateway); + return gateway.isEmpty ? 'ipfs://$cid' : '$gateway$cid'; + } + + static Future _copyKuboFileToMfs({ + required String endpoint, + required String cid, + required String fileName, + required String? authorization, + }) async { + final uploadUri = Uri.parse(endpoint); + final copyPath = uploadUri.path.replaceFirst( + RegExp(r'/add/?$'), + '/files/cp', + ); + if (copyPath == uploadUri.path) { + throw ArgumentError('Kubo upload endpoint must end with /add.'); + } + + final mfsPath = '/meshcore_uploads/$cid-$fileName'; + final copyUri = uploadUri.replace( + path: copyPath, + query: + 'arg=${Uri.encodeQueryComponent('/ipfs/$cid')}' + '&arg=${Uri.encodeQueryComponent(mfsPath)}&parents=true', + ); + final headers = authorization == null + ? {} + : {'Authorization': authorization}; + final client = httpClient; + final response = await (client == null + ? http.post(copyUri, headers: headers) + : client.post(copyUri, headers: headers)); + if (response.statusCode < 200 || response.statusCode >= 300) { + throw Exception( + 'Kubo MFS import failed (${response.statusCode}): ${response.body}', + ); + } + } + + static String _sanitizeUploadFileName(String name) { + final cleaned = name.replaceAll(RegExp(r'[<>:"/\\|?*]'), '_').trim(); + return cleaned.isEmpty ? 'shared-image' : cleaned; + } + + static String? _extractUploadCid(String body, {required bool isPinata}) { + final lines = const LineSplitter() + .convert(body) + .where((line) => line.trim().isNotEmpty) + .toList(); + for (final line in lines.reversed) { + try { + final decoded = jsonDecode(line); + if (decoded is! Map) continue; + final value = isPinata ? decoded['IpfsHash'] : decoded['Hash']; + if (value is String && value.isNotEmpty) return value; + } catch (_) { + continue; + } + } + return null; + } +} diff --git a/lib/helpers/message_url_image_helper.dart b/lib/helpers/message_url_image_helper.dart index 3f2a7835..30eb4e2f 100644 --- a/lib/helpers/message_url_image_helper.dart +++ b/lib/helpers/message_url_image_helper.dart @@ -1,10 +1,14 @@ import 'dart:async'; import 'dart:collection'; +import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:http/http.dart' as http; +import 'ipfs_upload_helper.dart'; +import '../models/app_settings.dart'; + /// Finds and renders image URLs embedded in ordinary text messages. /// /// This is deliberately separate from MeshCore's transmitted channel-image @@ -22,6 +26,41 @@ class MessageUrlImageHelper { @visibleForTesting static http.Client? httpClient; + /// Compatibility facade for the dedicated IPFS upload helper. + static Future uploadImageWithSettings({ + required AppSettings settings, + required Uint8List bytes, + required String fileName, + required String mimeType, + }) { + IpfsUploadHelper.httpClient = httpClient; + return IpfsUploadHelper.uploadImageWithSettings( + settings: settings, + bytes: bytes, + fileName: fileName, + mimeType: mimeType, + ); + } + + static Future uploadImage({ + required Uint8List bytes, + required String fileName, + required String mimeType, + required String uploadEndpoint, + required String uploadApiKey, + String uploadGateway = '', + }) async { + IpfsUploadHelper.httpClient = httpClient; + return IpfsUploadHelper.uploadImage( + bytes: bytes, + fileName: fileName, + mimeType: mimeType, + uploadEndpoint: uploadEndpoint, + uploadApiKey: uploadApiKey, + uploadGateway: uploadGateway, + ); + } + static final RegExp _pyxPattern = RegExp( r'''https?://pyx\.li/\?i=([A-Za-z0-9_-]+)''', caseSensitive: false, @@ -57,7 +96,10 @@ class MessageUrlImageHelper { _imagePattern.hasMatch(text); } - static Future parse(String text) async { + static Future parse( + String text, { + String publicGateway = AppSettings.defaultPublicIpfsGateway, + }) async { final trimmed = text.trim(); if (trimmed.isEmpty) return null; @@ -74,7 +116,9 @@ class MessageUrlImageHelper { final ipfsCidMatch = _ipfsCidPattern.firstMatch(trimmed); if (ipfsCidMatch != null) { final cid = _trimBoundary(ipfsCidMatch.group(1)!); - return 'https://ipfs.io/ipfs/$cid'; + final gateway = normalizeIpfsGateway(publicGateway); + if (gateway.isEmpty) return null; + return '$gateway$cid'; } final ibbMatch = _ibbSharePattern.firstMatch(trimmed); @@ -96,8 +140,11 @@ class MessageUrlImageHelper { return null; } - static Future parseVerified(String text) async { - final imageUrl = await parse(text); + static Future parseVerified( + String text, { + String publicGateway = AppSettings.defaultPublicIpfsGateway, + }) async { + final imageUrl = await parse(text, publicGateway: publicGateway); if (imageUrl == null) return null; final verified = await _verifyImageUrl(imageUrl); @@ -110,20 +157,22 @@ class MessageUrlImageHelper { /// be retried when a message is shown again. static Future parseVerifiedForMessage( String messageId, - String text, - ) { - final cached = _messageImageCache.remove(messageId); + String text, { + String publicGateway = AppSettings.defaultPublicIpfsGateway, + }) { + final cacheKey = '$messageId|$publicGateway'; + final cached = _messageImageCache.remove(cacheKey); if (cached != null) { - _messageImageCache[messageId] = cached; + _messageImageCache[cacheKey] = cached; return cached; } - final parsing = parseVerified(text); - _messageImageCache[messageId] = parsing; + final parsing = parseVerified(text, publicGateway: publicGateway); + _messageImageCache[cacheKey] = parsing; parsing.then((imageUrl) { if (imageUrl == null && - identical(_messageImageCache[messageId], parsing)) { - _messageImageCache.remove(messageId); + identical(_messageImageCache[cacheKey], parsing)) { + _messageImageCache.remove(cacheKey); } else if (imageUrl != null) { while (_messageImageCache.length > _maxMessageImageCacheEntries) { _messageImageCache.remove(_messageImageCache.keys.first); @@ -207,11 +256,13 @@ class MessageUrlImageFutureBuilder extends StatefulWidget { super.key, required this.messageId, required this.text, + required this.publicGateway, required this.builder, }); final String messageId; final String text; + final String publicGateway; final AsyncWidgetBuilder builder; @override @@ -229,6 +280,7 @@ class _MessageUrlImageFutureBuilderState _imageFuture = MessageUrlImageHelper.parseVerifiedForMessage( widget.messageId, widget.text, + publicGateway: widget.publicGateway, ); } @@ -239,6 +291,13 @@ class _MessageUrlImageFutureBuilderState _imageFuture = MessageUrlImageHelper.parseVerifiedForMessage( widget.messageId, widget.text, + publicGateway: widget.publicGateway, + ); + } else if (oldWidget.publicGateway != widget.publicGateway) { + _imageFuture = MessageUrlImageHelper.parseVerifiedForMessage( + widget.messageId, + widget.text, + publicGateway: widget.publicGateway, ); } } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index caa51590..a30412c9 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -448,6 +448,20 @@ "appSettings_routeWeightFailureDecrementSubtitle": "Weight removed from a path after failed delivery", "appSettings_maxMessageRetries": "Max Message Retries", "appSettings_maxMessageRetriesSubtitle": "Number of retry attempts before marking a message as failed", + "appSettings_ipfsImageLinks": "IPFS provider configuration", + "appSettings_ipfsImageLinksSubtitle": "Upload for url Images (or Files) via IPFS provider and default gateway to receive", + "appSettings_publicIpfsGateway": "Public gateway", + "appSettings_ipfsGatewayDeactivated": "Deactivated", + "appSettings_ipfsGatewayPinata": "Pinata", + "appSettings_ipfsGatewayFilebase": "Filebase", + "appSettings_ipfsGatewayCustom": "Custom (Kubo)", + "appSettings_uploadIpfsProvider": "Upload provider", + "appSettings_uploadIpfsGateway": "Upload gateway", + "appSettings_uploadIpfsGatewaySubtitle": "Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.", + "appSettings_uploadIpfsEndpoint": "Upload endpoint", + "appSettings_uploadIpfsEndpointSubtitle": "The API endpoint used to upload files", + "appSettings_uploadIpfsApiKey": "Upload API key", + "appSettings_ipfsImageLinksDescription": "Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.", "appSettings_battery": "Battery", "appSettings_batteryChemistry": "Battery Chemistry", "appSettings_batteryChemistryPerDevice": "Set per device ({deviceName})", @@ -910,6 +924,16 @@ "chat_removeGif": "Remove GIF", "chat_cancelReply": "Cancel reply", "chat_sendImageLora": "Send low-res image over radio", + "chat_sendImageIpfs": "Send image or file via IPFS", + "chat_ipfsUploadFailed": "IPFS upload failed: {error}", + "@chat_ipfsUploadFailed": { + "placeholders": { + "error": { + "type": "String" + } + } + }, + "chat_ipfsUploadNotConfigured": "Configure an IPFS upload provider in App Settings first.", "chat_imagePickFailed": "Couldn't open that image", "@chat_imagePickFailed": { "description": "Shown when picking or reading a photo to send fails" diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 4b1af121..4f1b928a 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -1924,6 +1924,90 @@ abstract class AppLocalizations { /// **'Number of retry attempts before marking a message as failed'** String get appSettings_maxMessageRetriesSubtitle; + /// No description provided for @appSettings_ipfsImageLinks. + /// + /// In en, this message translates to: + /// **'IPFS provider configuration'** + String get appSettings_ipfsImageLinks; + + /// No description provided for @appSettings_ipfsImageLinksSubtitle. + /// + /// In en, this message translates to: + /// **'Upload for url Images (or Files) via IPFS provider and default gateway to receive'** + String get appSettings_ipfsImageLinksSubtitle; + + /// No description provided for @appSettings_publicIpfsGateway. + /// + /// In en, this message translates to: + /// **'Public gateway'** + String get appSettings_publicIpfsGateway; + + /// No description provided for @appSettings_ipfsGatewayDeactivated. + /// + /// In en, this message translates to: + /// **'Deactivated'** + String get appSettings_ipfsGatewayDeactivated; + + /// No description provided for @appSettings_ipfsGatewayPinata. + /// + /// In en, this message translates to: + /// **'Pinata'** + String get appSettings_ipfsGatewayPinata; + + /// No description provided for @appSettings_ipfsGatewayFilebase. + /// + /// In en, this message translates to: + /// **'Filebase'** + String get appSettings_ipfsGatewayFilebase; + + /// No description provided for @appSettings_ipfsGatewayCustom. + /// + /// In en, this message translates to: + /// **'Custom (Kubo)'** + String get appSettings_ipfsGatewayCustom; + + /// No description provided for @appSettings_uploadIpfsProvider. + /// + /// In en, this message translates to: + /// **'Upload provider'** + String get appSettings_uploadIpfsProvider; + + /// No description provided for @appSettings_uploadIpfsGateway. + /// + /// In en, this message translates to: + /// **'Upload gateway'** + String get appSettings_uploadIpfsGateway; + + /// No description provided for @appSettings_uploadIpfsGatewaySubtitle. + /// + /// In en, this message translates to: + /// **'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'** + String get appSettings_uploadIpfsGatewaySubtitle; + + /// No description provided for @appSettings_uploadIpfsEndpoint. + /// + /// In en, this message translates to: + /// **'Upload endpoint'** + String get appSettings_uploadIpfsEndpoint; + + /// No description provided for @appSettings_uploadIpfsEndpointSubtitle. + /// + /// In en, this message translates to: + /// **'The API endpoint used to upload files'** + String get appSettings_uploadIpfsEndpointSubtitle; + + /// No description provided for @appSettings_uploadIpfsApiKey. + /// + /// In en, this message translates to: + /// **'Upload API key'** + String get appSettings_uploadIpfsApiKey; + + /// No description provided for @appSettings_ipfsImageLinksDescription. + /// + /// In en, this message translates to: + /// **'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'** + String get appSettings_ipfsImageLinksDescription; + /// No description provided for @appSettings_battery. /// /// In en, this message translates to: @@ -3112,6 +3196,24 @@ abstract class AppLocalizations { /// **'Send low-res image over radio'** String get chat_sendImageLora; + /// No description provided for @chat_sendImageIpfs. + /// + /// In en, this message translates to: + /// **'Send image or file via IPFS'** + String get chat_sendImageIpfs; + + /// No description provided for @chat_ipfsUploadFailed. + /// + /// In en, this message translates to: + /// **'IPFS upload failed: {error}'** + String chat_ipfsUploadFailed(String error); + + /// No description provided for @chat_ipfsUploadNotConfigured. + /// + /// In en, this message translates to: + /// **'Configure an IPFS upload provider in App Settings first.'** + String get chat_ipfsUploadNotConfigured; + /// Shown when picking or reading a photo to send fails /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index bb999a01..2cf51388 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -1058,6 +1058,52 @@ class AppLocalizationsBg extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Брой опити за повторно изпращане, преди съобщението да бъде маркирано като неуспешно.'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Батерия'; @@ -1749,6 +1795,18 @@ class AppLocalizationsBg extends AppLocalizations { @override String get chat_sendImageLora => 'Изпращане на изображение чрез MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Не мог да откривам та изображин'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 7c099a2a..4917478d 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -1053,6 +1053,52 @@ class AppLocalizationsDe extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Anzahl der Versuche, eine Nachricht erneut zu senden, bevor sie als fehlgeschlagen markiert wird.'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Akku'; @@ -1748,6 +1794,18 @@ class AppLocalizationsDe extends AppLocalizations { @override String get chat_sendImageLora => 'Bild über MeshCore senden'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Konnte dieses Bild nicht öffnen.'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index ce4fc6cc..3fb9d784 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -1037,6 +1037,52 @@ class AppLocalizationsEn extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Number of retry attempts before marking a message as failed'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Battery'; @@ -1717,6 +1763,18 @@ class AppLocalizationsEn extends AppLocalizations { @override String get chat_sendImageLora => 'Send low-res image over radio'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Couldn\'t open that image'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 21d23fdd..c67dda31 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -1050,6 +1050,52 @@ class AppLocalizationsEs extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Número de intentos de reintento antes de marcar un mensaje como fallido.'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Batería'; @@ -1744,6 +1790,18 @@ class AppLocalizationsEs extends AppLocalizations { @override String get chat_sendImageLora => 'Enviar imagen mediante MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'No pude abrir esa imagen'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 94a4133f..3c78016c 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -1056,6 +1056,52 @@ class AppLocalizationsFr extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Nombre de tentatives avant de marquer un message comme ayant échoué.'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Batterie'; @@ -1748,6 +1794,18 @@ class AppLocalizationsFr extends AppLocalizations { @override String get chat_sendImageLora => 'Envoyer une image via MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Je n\'ai pas pu ouvrir cette image'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index d02c4227..59442375 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -1045,6 +1045,52 @@ class AppLocalizationsHu extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Az üzenet sikertelenként való megjelölése előtti újrapróbálkozások száma'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Akkumulátor'; @@ -1738,6 +1784,18 @@ class AppLocalizationsHu extends AppLocalizations { @override String get chat_sendImageLora => 'Kép küldése MeshCore-on keresztül'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Nem tudtam ezt a fenti fényre kapni'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 877c0975..881a1b64 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -1056,6 +1056,52 @@ class AppLocalizationsIt extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Numero di tentativi di riprova prima di considerare un messaggio come fallito.'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Batteria'; @@ -1748,6 +1794,18 @@ class AppLocalizationsIt extends AppLocalizations { @override String get chat_sendImageLora => 'Invia immagine tramite MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Non sono riuscito ad aprire quell\'immagine'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 240eea50..7d745b3b 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -993,6 +993,52 @@ class AppLocalizationsJa extends AppLocalizations { @override String get appSettings_maxMessageRetriesSubtitle => 'メッセージを失敗として扱うまでの再試行回数'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'バッテリー'; @@ -1661,6 +1707,18 @@ class AppLocalizationsJa extends AppLocalizations { @override String get chat_sendImageLora => 'MeshCore経由で画像を送信'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'その画像を開けませんでした'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index d4b9be2d..f6a74b65 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -997,6 +997,52 @@ class AppLocalizationsKo extends AppLocalizations { @override String get appSettings_maxMessageRetriesSubtitle => '메시지를 실패로 처리하기 전 시도 횟수'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => '배터리'; @@ -1666,6 +1712,18 @@ class AppLocalizationsKo extends AppLocalizations { @override String get chat_sendImageLora => 'MeshCore를 통해 이미지 보내기'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => '그 이미지를 열 수 없었어요.'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index db418ab4..4b65ca26 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -1046,6 +1046,52 @@ class AppLocalizationsNl extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Aantal pogingen om een bericht opnieuw te versturen voordat het als mislukt wordt gemarkeerd'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Batterij'; @@ -1734,6 +1780,18 @@ class AppLocalizationsNl extends AppLocalizations { String get chat_sendImageLora => 'Afbeelding in lage resolutie via radio verzenden'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Kon die afbeelding niet openen'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index a1959873..c9864fd0 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -1062,6 +1062,52 @@ class AppLocalizationsPl extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Liczba prób ponownego wysłania wiadomości przed oznaczaniem jej jako nieudanej'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Bateria'; @@ -1763,6 +1809,18 @@ class AppLocalizationsPl extends AppLocalizations { @override String get chat_sendImageLora => 'Wyślij obraz przez MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Nie mogłem otworzyć tego obrazu'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index bab9270c..c0954bfe 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -1054,6 +1054,52 @@ class AppLocalizationsPt extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Número de tentativas de reenvio antes de classificar uma mensagem como falha.'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Bateria'; @@ -1744,6 +1790,18 @@ class AppLocalizationsPt extends AppLocalizations { @override String get chat_sendImageLora => 'Enviar imagem via MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Não consegui abrir essa imagem'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 4882c690..756e3276 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -1059,6 +1059,52 @@ class AppLocalizationsRu extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Количество попыток повторной отправки сообщения перед тем, как пометить его как неудачное.'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Батарея'; @@ -1748,6 +1794,18 @@ class AppLocalizationsRu extends AppLocalizations { @override String get chat_sendImageLora => 'Отправить изображение через MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Не удалось открыть это изображение'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 72213043..b86d8563 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -1045,6 +1045,52 @@ class AppLocalizationsSk extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Počet pokusov o odošleť pred označením správy ako neúspešnej'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Batéria'; @@ -1736,6 +1782,18 @@ class AppLocalizationsSk extends AppLocalizations { @override String get chat_sendImageLora => 'Odoslať obrázok cez MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Nesmiela jsem otvoriť tento obrázok'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index d84d6857..423a51c3 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -1047,6 +1047,52 @@ class AppLocalizationsSl extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Število poskusov ponovnega poslanja, preden se sporočilo označuje kot neuspešno'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Baterija'; @@ -1735,6 +1781,18 @@ class AppLocalizationsSl extends AppLocalizations { @override String get chat_sendImageLora => 'Pošlji sliko prek MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Nispeval sem tega ta slik'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index c760c91f..70ed34eb 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -1036,6 +1036,52 @@ class AppLocalizationsSv extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Antal försök att skicka om ett meddelande innan det markeras som misslyckat.'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Batteri'; @@ -1723,6 +1769,18 @@ class AppLocalizationsSv extends AppLocalizations { @override String get chat_sendImageLora => 'Skicka bild via MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Kunde inte öppna bilden'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index 72ef4c94..194fffc5 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -1049,6 +1049,52 @@ class AppLocalizationsUk extends AppLocalizations { String get appSettings_maxMessageRetriesSubtitle => 'Кількість спроб повторного відправлення повідомлення перед тим, як позначити його як невдале'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => 'Батарея'; @@ -1738,6 +1784,18 @@ class AppLocalizationsUk extends AppLocalizations { @override String get chat_sendImageLora => 'Надіслати зображення через MeshCore'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => 'Неможливо відкрити це изображення'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 88df6c9c..46ffc0ba 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -979,6 +979,52 @@ class AppLocalizationsZh extends AppLocalizations { @override String get appSettings_maxMessageRetriesSubtitle => '在将消息标记为失败之前,允许尝试的次数'; + @override + String get appSettings_ipfsImageLinks => 'IPFS provider configuration'; + + @override + String get appSettings_ipfsImageLinksSubtitle => + 'Upload for url Images (or Files) via IPFS provider and default gateway to receive'; + + @override + String get appSettings_publicIpfsGateway => 'Public gateway'; + + @override + String get appSettings_ipfsGatewayDeactivated => 'Deactivated'; + + @override + String get appSettings_ipfsGatewayPinata => 'Pinata'; + + @override + String get appSettings_ipfsGatewayFilebase => 'Filebase'; + + @override + String get appSettings_ipfsGatewayCustom => 'Custom (Kubo)'; + + @override + String get appSettings_uploadIpfsProvider => 'Upload provider'; + + @override + String get appSettings_uploadIpfsGateway => 'Upload gateway'; + + @override + String get appSettings_uploadIpfsGatewaySubtitle => + 'Gateway to share Image or File as url-link. Leave empty to use ipfs: format, which may not be opened by other clients.'; + + @override + String get appSettings_uploadIpfsEndpoint => 'Upload endpoint'; + + @override + String get appSettings_uploadIpfsEndpointSubtitle => + 'The API endpoint used to upload files'; + + @override + String get appSettings_uploadIpfsApiKey => 'Upload API key'; + + @override + String get appSettings_ipfsImageLinksDescription => + 'Public gateway downloads ipfs: format images. Upload gateway is used to generate share links for uploaded url images or files.'; + @override String get appSettings_battery => '电池'; @@ -1643,6 +1689,18 @@ class AppLocalizationsZh extends AppLocalizations { @override String get chat_sendImageLora => '通过 MeshCore 发送图片'; + @override + String get chat_sendImageIpfs => 'Send image or file via IPFS'; + + @override + String chat_ipfsUploadFailed(String error) { + return 'IPFS upload failed: $error'; + } + + @override + String get chat_ipfsUploadNotConfigured => + 'Configure an IPFS upload provider in App Settings first.'; + @override String get chat_imagePickFailed => '无法打开该图片'; diff --git a/lib/main.dart b/lib/main.dart index f5f54751..02550f25 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -132,6 +132,14 @@ void main() async { // Initialize notification service final notificationService = NotificationService(); + notificationService.setPublicIpfsGateway( + appSettingsService.settings.publicIpfsGateway, + ); + appSettingsService.addListener(() { + notificationService.setPublicIpfsGateway( + appSettingsService.settings.publicIpfsGateway, + ); + }); await notificationService.initialize(); await backgroundService.initialize(); backgroundService.setLanguageOverrideProvider( diff --git a/lib/models/app_settings.dart b/lib/models/app_settings.dart index ef954f28..99ef609a 100644 --- a/lib/models/app_settings.dart +++ b/lib/models/app_settings.dart @@ -3,6 +3,32 @@ import 'translation_support.dart'; enum UnitSystem { metric, imperial } +String normalizeIpfsGateway(String value) { + var gateway = value.trim(); + if (gateway.isEmpty) return gateway; + if (!gateway.startsWith('http://') && !gateway.startsWith('https://')) { + gateway = 'https://$gateway'; + } + gateway = gateway.replaceAll('{cid}', ''); + if (gateway.endsWith('/ipfs')) gateway = '$gateway/'; + if (!gateway.endsWith('/ipfs/')) { + gateway = '${gateway.endsWith('/') ? gateway : '$gateway/'}ipfs/'; + } + return gateway; +} + +String migratePublicIpfsGateway(String? value) { + final gateway = value?.trim(); + if (gateway == null || + gateway == 'https://ipfs.io/ipfs/' || + gateway == 'https://ipfs.io/ipfs' || + gateway == 'https://dweb.link/ipfs/' || + gateway == 'https://dweb.link/ipfs') { + return AppSettings.defaultPublicIpfsGateway; + } + return gateway; +} + extension UnitSystemValue on UnitSystem { String get value { switch (this) { @@ -78,6 +104,7 @@ class Cyr2LatProfile { class AppSettings { static const Object _unset = Object(); static const String stadiaDemo = '51bd0381-4685-4666-bae8-48940f6d77c0'; + static const String defaultPublicIpfsGateway = ''; final bool clearPathOnMaxRetry; final bool mapShowRepeaters; @@ -130,6 +157,10 @@ class AppSettings { final int tcpServerPort; final bool jumpToOldestUnread; final bool imageMessagesEnabled; + final String publicIpfsGateway; + final String uploadIpfsGateway; + final String uploadIpfsEndpoint; + final String uploadIpfsApiKey; /// Whether a received image is decoded as soon as it is reassembled. /// @@ -180,6 +211,10 @@ class AppSettings { return apiKey; } + String get effectiveUploadIpfsGateway { + return uploadIpfsGateway.trim(); + } + bool get usesstadiaDemo => effectiveMapTileApiKey == stadiaDemo; Map get cyr2latCharMap { @@ -239,6 +274,10 @@ class AppSettings { this.tcpServerPort = 0, this.jumpToOldestUnread = false, this.imageMessagesEnabled = false, + this.publicIpfsGateway = defaultPublicIpfsGateway, + this.uploadIpfsGateway = '', + this.uploadIpfsEndpoint = '', + this.uploadIpfsApiKey = '', this.imageProcessAutomatically = false, this.imageCodecEnabled = false, this.imageCodecSelectedModelId, @@ -321,6 +360,10 @@ class AppSettings { 'tcp_server_port': tcpServerPort, 'jump_to_oldest_unread': jumpToOldestUnread, 'image_messages_enabled': imageMessagesEnabled, + 'public_ipfs_gateway': publicIpfsGateway, + 'upload_ipfs_gateway': uploadIpfsGateway, + 'upload_ipfs_endpoint': uploadIpfsEndpoint, + 'upload_ipfs_api_key': uploadIpfsApiKey, 'image_process_automatically': imageProcessAutomatically, 'image_codec_enabled': imageCodecEnabled, 'image_codec_selected_model_id': imageCodecSelectedModelId, @@ -428,6 +471,12 @@ class AppSettings { tcpServerPort: json['tcp_server_port'] as int? ?? 0, jumpToOldestUnread: json['jump_to_oldest_unread'] as bool? ?? false, imageMessagesEnabled: json['image_messages_enabled'] as bool? ?? false, + publicIpfsGateway: migratePublicIpfsGateway( + json['public_ipfs_gateway'] as String?, + ), + uploadIpfsGateway: json['upload_ipfs_gateway'] as String? ?? '', + uploadIpfsEndpoint: json['upload_ipfs_endpoint'] as String? ?? '', + uploadIpfsApiKey: json['upload_ipfs_api_key'] as String? ?? '', imageProcessAutomatically: json['image_process_automatically'] as bool? ?? false, imageCodecEnabled: json['image_codec_enabled'] as bool? ?? false, @@ -548,6 +597,10 @@ class AppSettings { int? tcpServerPort, bool? jumpToOldestUnread, bool? imageMessagesEnabled, + String? publicIpfsGateway, + String? uploadIpfsGateway, + String? uploadIpfsEndpoint, + String? uploadIpfsApiKey, bool? imageProcessAutomatically, bool? imageCodecEnabled, Object? imageCodecSelectedModelId = _unset, @@ -633,6 +686,10 @@ class AppSettings { tcpServerPort: tcpServerPort ?? this.tcpServerPort, jumpToOldestUnread: jumpToOldestUnread ?? this.jumpToOldestUnread, imageMessagesEnabled: imageMessagesEnabled ?? this.imageMessagesEnabled, + publicIpfsGateway: publicIpfsGateway ?? this.publicIpfsGateway, + uploadIpfsGateway: uploadIpfsGateway ?? this.uploadIpfsGateway, + uploadIpfsEndpoint: uploadIpfsEndpoint ?? this.uploadIpfsEndpoint, + uploadIpfsApiKey: uploadIpfsApiKey ?? this.uploadIpfsApiKey, imageProcessAutomatically: imageProcessAutomatically ?? this.imageProcessAutomatically, imageCodecEnabled: imageCodecEnabled ?? this.imageCodecEnabled, diff --git a/lib/screens/app_settings_screen.dart b/lib/screens/app_settings_screen.dart index d32a443b..64325ac4 100644 --- a/lib/screens/app_settings_screen.dart +++ b/lib/screens/app_settings_screen.dart @@ -701,6 +701,18 @@ class AppSettingsScreen extends StatelessWidget { ), ], const Divider(height: 1, indent: 16), + ListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 4, + ), + leading: const Icon(Icons.link_outlined, size: 20), + title: Text(context.l10n.appSettings_ipfsImageLinks), + subtitle: Text(context.l10n.appSettings_ipfsImageLinksSubtitle), + trailing: const Icon(Icons.chevron_right, size: 18), + onTap: () => _showIpfsImageLinksDialog(context, settingsService), + ), + const Divider(height: 1, indent: 16), _ScrollIntoViewOnce( enabled: focusImageMessages, child: SwitchListTile( @@ -723,7 +735,6 @@ class AppSettingsScreen extends StatelessWidget { ), ), if (settingsService.settings.imageMessagesEnabled) ...[ - const Divider(height: 1, indent: 16), SwitchListTile( contentPadding: const EdgeInsets.symmetric( horizontal: 16, @@ -751,6 +762,16 @@ class AppSettingsScreen extends StatelessWidget { } } + void _showIpfsImageLinksDialog( + BuildContext context, + AppSettingsService settingsService, + ) { + showDialog( + context: context, + builder: (_) => _IpfsImageLinksDialog(settingsService: settingsService), + ); + } + /// Model registry for image messages: the download entry point, the /// downloaded weights, and — when the build simply cannot run the codec — /// [ImageCodecService.unavailableReason] instead of a dead download button. @@ -2649,6 +2670,311 @@ class AppSettingsScreen extends StatelessWidget { } } +class _IpfsImageLinksDialog extends StatefulWidget { + const _IpfsImageLinksDialog({required this.settingsService}); + + final AppSettingsService settingsService; + + @override + State<_IpfsImageLinksDialog> createState() => _IpfsImageLinksDialogState(); +} + +class _IpfsImageLinksDialogState extends State<_IpfsImageLinksDialog> { + late final TextEditingController _publicController; + late final TextEditingController _uploadGatewayController; + late final TextEditingController _endpointController; + late final TextEditingController _apiKeyController; + late final String _currentApiKey; + late final String _maskedApiKey; + late String _selectedGateway; + late String _selectedUploadProvider; + bool _apiKeyEditing = false; + bool _apiKeyChanged = false; + + @override + void initState() { + super.initState(); + final settings = widget.settingsService.settings; + _publicController = TextEditingController( + text: normalizeIpfsGateway(settings.publicIpfsGateway), + ); + _uploadGatewayController = TextEditingController( + text: normalizeIpfsGateway(settings.uploadIpfsGateway), + ); + _endpointController = TextEditingController( + text: settings.uploadIpfsEndpoint, + ); + _currentApiKey = settings.uploadIpfsApiKey.trim(); + _maskedApiKey = _currentApiKey.isEmpty ? '' : _maskApiKey(_currentApiKey); + _apiKeyController = TextEditingController(text: _maskedApiKey); + _selectedGateway = _gatewayPreset(_publicController.text); + _selectedUploadProvider = _uploadProvider( + _uploadGatewayController.text, + _endpointController.text, + _currentApiKey, + ); + } + + @override + void dispose() { + _publicController.dispose(); + _uploadGatewayController.dispose(); + _endpointController.dispose(); + _apiKeyController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final l10n = context.l10n; + return AlertDialog( + title: Text(l10n.appSettings_ipfsImageLinks), + content: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(l10n.appSettings_ipfsImageLinksDescription), + const SizedBox(height: 12), + DropdownButtonFormField( + initialValue: _selectedGateway, + isExpanded: true, + decoration: InputDecoration( + labelText: l10n.appSettings_publicIpfsGateway, + ), + items: [ + DropdownMenuItem( + value: 'deactivated', + child: Text(l10n.appSettings_ipfsGatewayDeactivated), + ), + DropdownMenuItem( + value: 'pinata', + child: Text(l10n.appSettings_ipfsGatewayPinata), + ), + DropdownMenuItem( + value: 'filebase', + child: Text(l10n.appSettings_ipfsGatewayFilebase), + ), + DropdownMenuItem( + value: 'custom', + child: Text(l10n.appSettings_ipfsGatewayCustom), + ), + ], + onChanged: _selectGateway, + ), + const SizedBox(height: 10), + TextField( + controller: _publicController, + decoration: InputDecoration( + labelText: l10n.appSettings_publicIpfsGateway, + ), + keyboardType: TextInputType.url, + autocorrect: false, + onChanged: (_) { + if (_selectedGateway != 'custom') { + setState(() => _selectedGateway = 'custom'); + } + }, + ), + const Divider(height: 20), + DropdownButtonFormField( + initialValue: _selectedUploadProvider, + isExpanded: true, + decoration: InputDecoration( + labelText: l10n.appSettings_uploadIpfsProvider, + ), + items: [ + DropdownMenuItem( + value: 'pinata', + child: Text(l10n.appSettings_ipfsGatewayPinata), + ), + DropdownMenuItem( + value: 'filebase', + child: Text(l10n.appSettings_ipfsGatewayFilebase), + ), + DropdownMenuItem( + value: 'custom', + child: Text(l10n.appSettings_ipfsGatewayCustom), + ), + DropdownMenuItem( + value: 'deactivated', + child: Text(l10n.appSettings_ipfsGatewayDeactivated), + ), + ], + onChanged: _selectUploadProvider, + ), + const SizedBox(height: 10), + TextField( + controller: _uploadGatewayController, + decoration: InputDecoration( + labelText: l10n.appSettings_uploadIpfsGateway, + helperText: l10n.appSettings_uploadIpfsGatewaySubtitle, + helperMaxLines: 3, + ), + keyboardType: TextInputType.url, + autocorrect: false, + onChanged: (_) => _markCustomUploadProvider(), + ), + const SizedBox(height: 10), + TextField( + controller: _endpointController, + decoration: InputDecoration( + labelText: l10n.appSettings_uploadIpfsEndpoint, + helperText: l10n.appSettings_uploadIpfsEndpointSubtitle, + helperMaxLines: 3, + ), + keyboardType: TextInputType.url, + autocorrect: false, + onChanged: (_) => _markCustomUploadProvider(), + ), + const SizedBox(height: 10), + TextField( + controller: _apiKeyController, + decoration: InputDecoration( + labelText: l10n.appSettings_uploadIpfsApiKey, + ), + autocorrect: false, + enableSuggestions: false, + onTap: () { + if (_apiKeyEditing) return; + setState(() { + _apiKeyEditing = true; + _apiKeyController.clear(); + }); + }, + onChanged: (_) { + _apiKeyChanged = true; + _markCustomUploadProvider(); + }, + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text(l10n.common_cancel), + ), + TextButton(onPressed: _save, child: Text(l10n.common_save)), + ], + ); + } + + void _selectGateway(String? value) { + if (value == null) return; + setState(() { + _selectedGateway = value; + final preset = _gatewayValue(value); + if (preset != null) _publicController.text = preset; + }); + } + + void _selectUploadProvider(String? value) { + if (value == null) return; + setState(() { + _selectedUploadProvider = value; + final preset = _uploadPreset(value); + if (preset != null) { + _uploadGatewayController.text = preset.gateway; + _endpointController.text = preset.endpoint; + if (value == 'deactivated') _apiKeyController.clear(); + } + }); + } + + void _markCustomUploadProvider() { + if (_selectedUploadProvider != 'custom') { + setState(() => _selectedUploadProvider = 'custom'); + } + } + + Future _save() async { + final deactivated = _selectedUploadProvider == 'deactivated'; + await widget.settingsService.setIpfsImageSettings( + publicGateway: _publicController.text, + uploadGateway: deactivated ? '' : _uploadGatewayController.text, + uploadEndpoint: deactivated ? '' : _endpointController.text, + uploadApiKey: deactivated + ? '' + : _apiKeyChanged + ? _apiKeyController.text + : _currentApiKey, + ); + if (mounted) Navigator.pop(context); + } + + String _gatewayPreset(String value) { + if (value.isEmpty) return 'deactivated'; + if (value == 'https://gateway.pinata.cloud/ipfs/' || + value == 'https://gateway.pinata.cloud/ipfs') { + return 'pinata'; + } + if (value == 'https://ipfs.filebase.io/ipfs/' || + value == 'https://ipfs.filebase.io/ipfs') { + return 'filebase'; + } + return 'custom'; + } + + String? _gatewayValue(String preset) { + switch (preset) { + case 'deactivated': + return ''; + case 'pinata': + return 'https://gateway.pinata.cloud/ipfs/'; + case 'filebase': + return 'https://ipfs.filebase.io/ipfs/'; + case 'custom': + return 'http://127.0.0.1:8080/ipfs/'; + default: + return null; + } + } + + String _uploadProvider(String gateway, String endpoint, String apiKey) { + if (gateway.isEmpty && endpoint.isEmpty && apiKey.isEmpty) { + return 'deactivated'; + } + if (gateway == 'https://gateway.pinata.cloud/ipfs/' && + endpoint == 'https://api.pinata.cloud/pinning/pinFileToIPFS') { + return 'pinata'; + } + if (gateway == 'https://ipfs.filebase.io/ipfs/' && + endpoint == 'https://rpc.filebase.io/api/v0/add') { + return 'filebase'; + } + return 'custom'; + } + + ({String gateway, String endpoint})? _uploadPreset(String preset) { + switch (preset) { + case 'pinata': + return ( + gateway: 'https://gateway.pinata.cloud/ipfs/', + endpoint: 'https://api.pinata.cloud/pinning/pinFileToIPFS', + ); + case 'filebase': + return ( + gateway: 'https://ipfs.filebase.io/ipfs/', + endpoint: 'https://rpc.filebase.io/api/v0/add', + ); + case 'custom': + return ( + gateway: 'http://127.0.0.1:8080/ipfs/', + endpoint: 'http://127.0.0.1:5001/api/v0/add', + ); + case 'deactivated': + return (gateway: '', endpoint: ''); + default: + return null; + } + } + + String _maskApiKey(String value) { + if (value.length <= 8) return '********'; + return '${value.substring(0, 4)}...${value.substring(value.length - 4)}'; + } +} + /// Owns the [TextEditingController] for the manual model URL field so it /// survives rebuilds of the parent [Consumer3]. class _TranslationUrlField extends StatefulWidget { diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 7f592dd5..3ec9a4bd 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -6,6 +6,7 @@ import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; +import 'package:file_selector/file_selector.dart' as file_selector; import 'package:image_picker/image_picker.dart'; import 'package:provider/provider.dart'; @@ -18,6 +19,7 @@ import '../helpers/chat_scroll_controller.dart'; import '../connector/meshcore_protocol.dart'; import '../helpers/cyr2lat.dart'; import '../helpers/gif_helper.dart'; +import '../helpers/ipfs_upload_helper.dart'; import '../helpers/message_url_image_helper.dart'; import '../helpers/path_helper.dart'; import '../helpers/reaction_helper.dart'; @@ -40,7 +42,6 @@ import '../widgets/received_image_message.dart'; import '../widgets/byte_count_input.dart'; import '../widgets/chat_day_separator.dart'; import '../widgets/empty_state.dart'; - import '../widgets/chat_zoom_wrapper.dart'; import '../widgets/emoji_picker.dart'; import '../widgets/gif_message.dart'; @@ -613,6 +614,7 @@ class _ChannelChatScreenState extends State { bool urlImagesEnabled, ) { final settingsService = context.watch(); + final publicIpfsGateway = settingsService.settings.publicIpfsGateway; final enableTracing = settingsService.settings.enableMessageTracing; final regionOnHopsLine = settingsService.settings.regionOnHopsLine; final isOutgoing = message.isOutgoing; @@ -788,6 +790,7 @@ class _ChannelChatScreenState extends State { MessageUrlImageFutureBuilder( messageId: message.messageId, text: message.text, + publicGateway: publicIpfsGateway, builder: (context, snapshot) { final imageAttachment = snapshot.data; @@ -1360,6 +1363,113 @@ class _ChannelChatScreenState extends State { ); } + Future _sendImageViaIpfs() async { + final l10n = context.l10n; + final settings = context.read().settings; + if (settings.uploadIpfsEndpoint.trim().isEmpty) { + showDismissibleSnackBar( + context, + content: Text(l10n.chat_ipfsUploadNotConfigured), + ); + return; + } + + final file_selector.XFile? file; + try { + file = await file_selector.openFile(); + } on Exception catch (error) { + if (!mounted) return; + showDismissibleSnackBar( + context, + content: Text(l10n.chat_ipfsUploadFailed('$error')), + ); + return; + } + if (file == null) return; + if (!mounted) return; + + final Uint8List bytes; + try { + bytes = await file.readAsBytes(); + } on Exception catch (error) { + if (!mounted) return; + showDismissibleSnackBar( + context, + content: Text(l10n.chat_ipfsUploadFailed('$error')), + ); + return; + } + if (!mounted) return; + if (bytes.isEmpty) { + showDismissibleSnackBar( + context, + content: Text( + l10n.chat_ipfsUploadFailed('The selected file is empty.'), + ), + ); + return; + } + + final String messageUrl; + try { + messageUrl = await IpfsUploadHelper.uploadImageWithSettings( + settings: settings, + bytes: bytes, + fileName: file.name, + mimeType: IpfsUploadHelper.mimeTypeForFileName(file.name), + ); + } on Exception catch (error) { + if (!mounted) return; + showDismissibleSnackBar( + context, + content: Text(l10n.chat_ipfsUploadFailed('$error')), + ); + return; + } + if (!mounted) return; + + final connector = context.read(); + final existingText = _textController.text.trim(); + final combinedText = existingText.isEmpty + ? '$messageUrl ' + : '$messageUrl\n$existingText'; + final maxBytes = maxChannelMessageBytes(connector.selfName); + var messageText = combinedText; + var outboundText = connector.prepareChannelOutboundText( + widget.channel.index, + messageText, + ); + if (utf8.encode(outboundText).length > maxBytes && + existingText.isNotEmpty) { + final originalCharacters = existingText.characters.toList(); + for (var count = originalCharacters.length - 1; count >= 0; count--) { + final shortened = originalCharacters.take(count).join(); + final candidate = '$messageUrl\n$shortened'; + final encoded = connector.prepareChannelOutboundText( + widget.channel.index, + candidate, + ); + if (utf8.encode(encoded).length <= maxBytes) { + messageText = candidate; + outboundText = encoded; + break; + } + } + } + if (utf8.encode(outboundText).length > maxBytes) { + showDismissibleSnackBar( + context, + content: Text(context.l10n.chat_messageTooLong(maxBytes)), + ); + return; + } + _textController.value = TextEditingValue( + text: messageText, + selection: TextSelection.collapsed(offset: messageText.length), + ); + _textFieldFocusNode.requestFocus(); + } + /// Takes no [BuildContext]: it uses the [State]'s own, so the `mounted` /// checks around each `await` are the ones that actually govern it. Future _showImageSendPreview() async { @@ -2110,6 +2220,20 @@ class _ChannelChatScreenState extends State { ), ); } + if (settings.uploadIpfsEndpoint.trim().isNotEmpty) { + items.add( + PopupMenuItem( + value: 'ipfs-image', + child: Row( + children: [ + const Icon(Icons.cloud_upload_outlined), + const SizedBox(width: 12), + Text(context.l10n.chat_sendImageIpfs), + ], + ), + ), + ); + } final selfConnector = context .read(); if (hasShareableLocation( @@ -2159,6 +2283,9 @@ class _ChannelChatScreenState extends State { case 'meshcore-image': _showImageSendPreview(); break; + case 'ipfs-image': + _sendImageViaIpfs(); + break; case 'send-my-location': await _shareMyLocation( context.read(), diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index e5d71c3f..348c61fc 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; +import 'package:file_selector/file_selector.dart' as file_selector; import 'package:provider/provider.dart'; import '../utils/app_logger.dart'; @@ -20,6 +21,7 @@ import '../widgets/message_status_icon.dart'; import '../widgets/empty_state.dart'; import '../helpers/chat_scroll_controller.dart'; import '../helpers/gif_helper.dart'; +import '../helpers/ipfs_upload_helper.dart'; import '../models/channel_message.dart'; import '../models/contact.dart'; import '../l10n/contact_localization.dart'; @@ -507,7 +509,46 @@ class _ChatScreenState extends State { Offset.zero, ancestor: overlay, ); - const menuHeight = 2 * kMinInteractiveDimension + 16; + final items = >[ + PopupMenuItem( + value: 'gif', + child: Row( + children: [ + const Icon(Icons.gif_box), + const SizedBox(width: 12), + Text(context.l10n.chat_sendGif), + ], + ), + ), + ]; + if (settings.uploadIpfsEndpoint.trim().isNotEmpty) { + items.add( + PopupMenuItem( + value: 'ipfs-image', + child: Row( + children: [ + const Icon(Icons.cloud_upload_outlined), + const SizedBox(width: 12), + Text(context.l10n.chat_sendImageIpfs), + ], + ), + ), + ); + } + items.add( + PopupMenuItem( + value: 'send-my-location', + child: Row( + children: [ + const Icon(Icons.my_location), + const SizedBox(width: 12), + Text(context.l10n.chat_shareMyLocation), + ], + ), + ), + ); + final menuHeight = + items.length * kMinInteractiveDimension + 16; final menuTop = (buttonOffset.dy - menuHeight).clamp( 8.0, overlay.size.height, @@ -524,28 +565,7 @@ class _ChatScreenState extends State { final selected = await showMenu( context: menuContext, position: position, - items: [ - PopupMenuItem( - value: 'gif', - child: Row( - children: [ - const Icon(Icons.gif_box), - const SizedBox(width: 12), - Text(context.l10n.chat_sendGif), - ], - ), - ), - PopupMenuItem( - value: 'send-my-location', - child: Row( - children: [ - const Icon(Icons.my_location), - const SizedBox(width: 12), - Text(context.l10n.chat_shareMyLocation), - ], - ), - ), - ], + items: items, ); if (!mounted || !menuContext.mounted) return; if (selected == null) return; @@ -553,6 +573,9 @@ class _ChatScreenState extends State { case 'gif': _showGifPicker(context); break; + case 'ipfs-image': + _sendImageViaIpfs(); + break; case 'send-my-location': await _shareMyLocation( context.read(), @@ -572,6 +595,7 @@ class _ChatScreenState extends State { // No image button here: the image wire format is GRP_DATA, a // channel primitive with no DM equivalent (see the note at the // top of this file). + // IPFS shares a URL as ordinary text instead. Expanded( child: ValueListenableBuilder( valueListenable: _textController, @@ -722,6 +746,112 @@ class _ChatScreenState extends State { ); } + Future _sendImageViaIpfs() async { + final l10n = context.l10n; + final settings = context.read().settings; + if (settings.uploadIpfsEndpoint.trim().isEmpty) { + showDismissibleSnackBar( + context, + content: Text(l10n.chat_ipfsUploadNotConfigured), + ); + return; + } + + final file_selector.XFile? file; + try { + file = await file_selector.openFile(); + } on Exception catch (error) { + if (!mounted) return; + showDismissibleSnackBar( + context, + content: Text(l10n.chat_ipfsUploadFailed('$error')), + ); + return; + } + if (file == null || !mounted) return; + + final Uint8List bytes; + try { + bytes = await file.readAsBytes(); + } on Exception catch (error) { + if (!mounted) return; + showDismissibleSnackBar( + context, + content: Text(l10n.chat_ipfsUploadFailed('$error')), + ); + return; + } + if (!mounted) return; + if (bytes.isEmpty) { + showDismissibleSnackBar( + context, + content: Text( + l10n.chat_ipfsUploadFailed('The selected file is empty.'), + ), + ); + return; + } + + final String messageUrl; + try { + messageUrl = await IpfsUploadHelper.uploadImageWithSettings( + settings: settings, + bytes: bytes, + fileName: file.name, + mimeType: IpfsUploadHelper.mimeTypeForFileName(file.name), + ); + } on Exception catch (error) { + if (!mounted) return; + showDismissibleSnackBar( + context, + content: Text(l10n.chat_ipfsUploadFailed('$error')), + ); + return; + } + if (!mounted) return; + + final connector = context.read(); + final contact = _resolveContact(connector); + final existingText = _textController.text.trim(); + var messageText = existingText.isEmpty + ? '$messageUrl ' + : '$messageUrl\n$existingText'; + final maxBytes = maxContactMessageBytes(); + var encodedText = connector.prepareContactOutboundText( + contact, + messageText, + ); + if (utf8.encode(encodedText).length > maxBytes && existingText.isNotEmpty) { + final originalCharacters = existingText.characters.toList(); + for (var count = originalCharacters.length - 1; count >= 0; count--) { + final shortened = originalCharacters.take(count).join(); + final candidate = '$messageUrl\n$shortened'; + final candidateEncoded = connector.prepareContactOutboundText( + contact, + candidate, + ); + if (utf8.encode(candidateEncoded).length <= maxBytes) { + messageText = candidate; + encodedText = candidateEncoded; + break; + } + } + } + if (utf8.encode(encodedText).length > maxBytes) { + showDismissibleSnackBar( + context, + content: Text(l10n.chat_messageTooLong(maxBytes)), + ); + return; + } + + _textController.value = TextEditingValue( + text: messageText, + selection: TextSelection.collapsed(offset: messageText.length), + ); + _textFieldFocusNode.requestFocus(); + } + Future _showTranslationOptions() async { final settingsService = context.read(); final settings = settingsService.settings; @@ -1502,6 +1632,7 @@ class _MessageBubble extends StatelessWidget { final urlImagesEnabled = context.select( (connector) => connector.isContactUrlImagesEnabled(sourceId), ); + final publicIpfsGateway = settingsService.settings.publicIpfsGateway; // Bubble colors — outgoing uses MeshPalette.me / meBorder / meInk. final bubbleColor = isFailed @@ -1664,6 +1795,7 @@ class _MessageBubble extends StatelessWidget { MessageUrlImageFutureBuilder( messageId: message.messageId, text: message.text, + publicGateway: publicIpfsGateway, builder: (context, snapshot) { final imageAttachment = snapshot.data; diff --git a/lib/services/app_settings_service.dart b/lib/services/app_settings_service.dart index 5a810588..42f4d33a 100644 --- a/lib/services/app_settings_service.dart +++ b/lib/services/app_settings_service.dart @@ -317,6 +317,24 @@ class AppSettingsService extends ChangeNotifier { await updateSettings(_settings.copyWith(imageMessagesEnabled: value)); } + Future setIpfsImageSettings({ + required String publicGateway, + required String uploadGateway, + required String uploadEndpoint, + required String uploadApiKey, + }) async { + final normalizedPublicGateway = normalizeIpfsGateway(publicGateway); + final normalizedUploadGateway = normalizeIpfsGateway(uploadGateway); + await updateSettings( + _settings.copyWith( + publicIpfsGateway: normalizedPublicGateway, + uploadIpfsGateway: normalizedUploadGateway, + uploadIpfsEndpoint: uploadEndpoint.trim(), + uploadIpfsApiKey: uploadApiKey.trim(), + ), + ); + } + /// See [AppSettings.imageProcessAutomatically]. `main.dart` mirrors this into /// `ReceivedImageStore.processAutomatically` on every settings change; the /// store applies it to future arrivals only, so flipping it does not diff --git a/lib/services/notification_service.dart b/lib/services/notification_service.dart index 66963a39..3e457138 100644 --- a/lib/services/notification_service.dart +++ b/lib/services/notification_service.dart @@ -11,6 +11,7 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import '../helpers/message_url_image_helper.dart'; import '../helpers/reaction_helper.dart'; import '../l10n/app_localizations.dart'; +import '../models/app_settings.dart'; import '../storage/prefs_manager.dart'; import '../utils/platform_info.dart'; import 'notification_reply.dart'; @@ -26,6 +27,11 @@ class NotificationService { // Locale for localized notification strings Locale _locale = const Locale('en'); + String _publicIpfsGateway = AppSettings.defaultPublicIpfsGateway; + + void setPublicIpfsGateway(String gateway) { + _publicIpfsGateway = gateway.trim(); + } /// Set the locale for notification strings (call when app locale changes) void setLocale(Locale locale) { @@ -297,7 +303,10 @@ class NotificationService { }) async { if (!urlImagesEnabled) return null; - final imageUrl = await MessageUrlImageHelper.parseVerified(text); + final imageUrl = await MessageUrlImageHelper.parseVerified( + text, + publicGateway: _publicIpfsGateway, + ); if (imageUrl == null) return null; try { diff --git a/test/helpers/message_url_image_helper_test.dart b/test/helpers/message_url_image_helper_test.dart index 11e1b022..35f9a6a2 100644 --- a/test/helpers/message_url_image_helper_test.dart +++ b/test/helpers/message_url_image_helper_test.dart @@ -1,3 +1,5 @@ +import 'dart:typed_data'; + import 'package:flutter_test/flutter_test.dart'; import 'package:http/http.dart' as http; import 'package:http/testing.dart'; @@ -48,29 +50,94 @@ void main() { ); }); - test('parses direct ipfs cid urls', () async { - final attachment = await MessageUrlImageHelper.parse( - 'my picture: ipfs://bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text', - ); + test( + 'does not resolve ipfs cid links with the default gateway deactivated', + () async { + expect( + await MessageUrlImageHelper.parse( + 'my picture: ipfs://bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text', + ), + isNull, + ); + expect( + await MessageUrlImageHelper.parse( + 'my picture: ipfs:bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text', + ), + isNull, + ); + }, + ); - expect(attachment, isNotNull); - expect( - attachment, - 'https://ipfs.io/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', - ); - }); - - test('parses direct ipfs cid urls without double slashes', () async { + test('uses the configured public gateway for direct ipfs cid urls', () async { final attachment = await MessageUrlImageHelper.parse( - 'my picture: ipfs:bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text', + 'ipfs://bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', + publicGateway: 'https://gateway.example.com', ); expect( attachment, - 'https://ipfs.io/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', + 'https://gateway.example.com/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', ); }); + test( + 'does not resolve ipfs cid links when the download gateway is empty', + () async { + final attachment = await MessageUrlImageHelper.parse( + 'ipfs://bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', + publicGateway: '', + ); + + expect(attachment, isNull); + }, + ); + + test('does not upload when the upload endpoint is empty', () async { + var requestCount = 0; + MessageUrlImageHelper.httpClient = MockClient((request) async { + requestCount++; + return http.Response('{}', 200); + }); + + await expectLater( + MessageUrlImageHelper.uploadImage( + bytes: Uint8List.fromList([1, 2, 3]), + fileName: 'image.png', + mimeType: 'image/png', + uploadEndpoint: '', + uploadApiKey: '', + ), + throwsArgumentError, + ); + expect(requestCount, 0); + }); + + test( + 'uploads and returns an ipfs scheme when upload gateway is empty', + () async { + MessageUrlImageHelper.httpClient = MockClient((request) async { + expect(request.method, 'POST'); + return http.Response( + '{"Hash":"bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly"}', + 200, + ); + }); + + final message = await MessageUrlImageHelper.uploadImage( + bytes: Uint8List.fromList([1, 2, 3]), + fileName: 'image.png', + mimeType: 'image/png', + uploadEndpoint: 'http://127.0.0.1:5001/api/v0/add', + uploadApiKey: '', + ); + + expect( + message, + 'ipfs://bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', + ); + }, + ); + test('parses http image urls', () async { final attachment = await MessageUrlImageHelper.parse( 'see this image https://example.com/picture.png?size=large additional text', diff --git a/test/models/model_changes_test.dart b/test/models/model_changes_test.dart index b96666e3..6cd5dc04 100644 --- a/test/models/model_changes_test.dart +++ b/test/models/model_changes_test.dart @@ -443,6 +443,23 @@ void main() { expect(settings.evictDiscoveredContactsEnabled, isFalse); }); + test('public IPFS gateway defaults to deactivated and preserves empty', () { + expect(AppSettings.fromJson({}).publicIpfsGateway, isEmpty); + expect( + AppSettings.fromJson({'public_ipfs_gateway': ''}).publicIpfsGateway, + isEmpty, + ); + }); + + test('empty upload gateway does not fall back to the download gateway', () { + final settings = AppSettings( + publicIpfsGateway: 'https://gateway.example.com/ipfs/', + uploadIpfsGateway: '', + ); + + expect(settings.effectiveUploadIpfsGateway, isEmpty); + }); + test( 'fromJson with missing new fields uses defaults (backward compat)', () { diff --git a/test/services/tcp_transport_service_native_test.dart b/test/services/tcp_transport_service_native_test.dart index 3cb9629c..72edf22e 100644 --- a/test/services/tcp_transport_service_native_test.dart +++ b/test/services/tcp_transport_service_native_test.dart @@ -61,34 +61,30 @@ int _readIntOption(Socket socket, int level, int option) { } void main() { - test( - 'connect enables TCP keepalive with short probe timings', - () async { - final server = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0); - final overrides = _CapturingConnectOverrides(); - final service = TcpTransportService(); - try { - await IOOverrides.runZoned( - () => service.connect( - host: InternetAddress.loopbackIPv4.address, - port: server.port, - ), - socketConnect: overrides.socketConnect, - ); - final socket = overrides.socket!; - // Linux values: SO_KEEPALIVE 9, TCP_KEEPIDLE 4, TCP_KEEPINTVL 5, - // TCP_KEEPCNT 6. - expect(_readIntOption(socket, RawSocketOption.levelSocket, 9), 1); - expect(_readIntOption(socket, RawSocketOption.levelTcp, 4), 30); - expect(_readIntOption(socket, RawSocketOption.levelTcp, 5), 10); - expect(_readIntOption(socket, RawSocketOption.levelTcp, 6), 3); - } finally { - await service.disconnect(); - await server.close(); - } - }, - skip: Platform.isLinux ? false : 'Option numbers checked are Linux ones', - ); + test('connect enables TCP keepalive with short probe timings', () async { + final server = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0); + final overrides = _CapturingConnectOverrides(); + final service = TcpTransportService(); + try { + await IOOverrides.runZoned( + () => service.connect( + host: InternetAddress.loopbackIPv4.address, + port: server.port, + ), + socketConnect: overrides.socketConnect, + ); + final socket = overrides.socket!; + // Linux values: SO_KEEPALIVE 9, TCP_KEEPIDLE 4, TCP_KEEPINTVL 5, + // TCP_KEEPCNT 6. + expect(_readIntOption(socket, RawSocketOption.levelSocket, 9), 1); + expect(_readIntOption(socket, RawSocketOption.levelTcp, 4), 30); + expect(_readIntOption(socket, RawSocketOption.levelTcp, 5), 10); + expect(_readIntOption(socket, RawSocketOption.levelTcp, 6), 3); + } finally { + await service.disconnect(); + await server.close(); + } + }, skip: Platform.isLinux ? false : 'Option numbers checked are Linux ones'); test('connect/disconnect updates TCP transport state', () async { final server = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0); diff --git a/untranslated.json b/untranslated.json index 9e26dfee..c4c655a3 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1 +1,341 @@ -{} \ No newline at end of file +{ + "bg": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "de": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "es": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "fr": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "hu": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "it": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "ja": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "ko": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "nl": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "pl": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "pt": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "ru": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "sk": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "sl": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "sv": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "uk": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ], + + "zh": [ + "appSettings_ipfsImageLinks", + "appSettings_ipfsImageLinksSubtitle", + "appSettings_publicIpfsGateway", + "appSettings_ipfsGatewayDeactivated", + "appSettings_ipfsGatewayPinata", + "appSettings_ipfsGatewayFilebase", + "appSettings_ipfsGatewayCustom", + "appSettings_uploadIpfsProvider", + "appSettings_uploadIpfsGateway", + "appSettings_uploadIpfsGatewaySubtitle", + "appSettings_uploadIpfsEndpoint", + "appSettings_uploadIpfsEndpointSubtitle", + "appSettings_uploadIpfsApiKey", + "appSettings_ipfsImageLinksDescription", + "chat_sendImageIpfs", + "chat_ipfsUploadFailed", + "chat_ipfsUploadNotConfigured" + ] +}