diff --git a/lib/utils/customization/application_customization.dart b/lib/utils/customization/application_customization.dart index 29de9d43..2c48bc5a 100644 --- a/lib/utils/customization/application_customization.dart +++ b/lib/utils/customization/application_customization.dart @@ -32,7 +32,9 @@ class ApplicationCustomization { static const _defaultAppName = 'privacyIDEA Authenticator'; static const _defaultWebsiteLink = 'https://netknights.it/'; static const _defaultCrashRecipient = 'app-crash@netknights.it'; + static const _defaultCrashSubjectPrefix = '(\$version) privacyIDEA Authenticator >>>'; static const _defaultFeedbackRecipient = 'app-crash@netknights.it'; + static const _defaultFeedbackSubjectPrefix = '(\$version) privacyIDEA Authenticator >>> [Feedback]'; static const String _defaultFontName = 'defaultFont'; final String fontFamilyName; @@ -69,7 +71,9 @@ class ApplicationCustomization { final String appName; final String websiteLink; final String crashRecipient; + final String crashSubjectPrefix; final String feedbackRecipient; + final String feedbackSubjectPrefix; final WidgetImage appbarIcon; static const String appbarIconFileName = 'appbar_icon'; final WidgetImage splashScreenImage; @@ -87,7 +91,9 @@ class ApplicationCustomization { this.appName = _defaultAppName, this.websiteLink = _defaultWebsiteLink, this.crashRecipient = _defaultCrashRecipient, + this.crashSubjectPrefix = _defaultCrashSubjectPrefix, this.feedbackRecipient = _defaultFeedbackRecipient, + this.feedbackSubjectPrefix = _defaultFeedbackSubjectPrefix, this.fontFamilyName = _defaultFontName, this.customFontBytes, WidgetImage? appbarIcon, @@ -108,7 +114,9 @@ class ApplicationCustomization { String? appName, String? websiteLink, String? crashRecipient, + String? crashSubjectPrefix, String? feedbackRecipient, + String? feedbackSubjectPrefix, WidgetImage? appbarIcon, WidgetImage? splashScreenImage, WidgetImage? backgroundImage, @@ -121,7 +129,9 @@ class ApplicationCustomization { appName: appName ?? this.appName, websiteLink: websiteLink ?? this.websiteLink, crashRecipient: crashRecipient ?? this.crashRecipient, + crashSubjectPrefix: crashSubjectPrefix ?? this.crashSubjectPrefix, feedbackRecipient: feedbackRecipient ?? this.feedbackRecipient, + feedbackSubjectPrefix: feedbackSubjectPrefix ?? this.feedbackSubjectPrefix, fontFamilyName: fontFamilyName, customFontBytes: customFontBytes, appbarIcon: appbarIcon ?? this.appbarIcon, @@ -140,7 +150,9 @@ class ApplicationCustomization { appName == other.appName && websiteLink == other.websiteLink && crashRecipient == other.crashRecipient && + crashSubjectPrefix == other.crashSubjectPrefix && feedbackRecipient == other.feedbackRecipient && + feedbackSubjectPrefix == other.feedbackSubjectPrefix && fontFamilyName == other.fontFamilyName && customFontBytes == other.customFontBytes && appbarIcon == other.appbarIcon && @@ -156,7 +168,9 @@ class ApplicationCustomization { appName, websiteLink, crashRecipient, + crashSubjectPrefix, feedbackRecipient, + feedbackSubjectPrefix, fontFamilyName, customFontBytes, appbarIcon, @@ -173,7 +187,9 @@ class ApplicationCustomization { appName: appName, websiteLink: websiteLink, crashRecipient: crashRecipient, + crashSubjectPrefix: crashSubjectPrefix, feedbackRecipient: feedbackRecipient, + feedbackSubjectPrefix: feedbackSubjectPrefix, fontFamilyName: fontName, customFontBytes: fontBytes, appbarIcon: appbarIcon, @@ -203,7 +219,9 @@ class ApplicationCustomization { appName: json['appName'] as String? ?? _defaultAppName, websiteLink: json['websiteLink'] as String? ?? _defaultWebsiteLink, crashRecipient: json['crashRecipient'] as String? ?? _defaultCrashRecipient, + crashSubjectPrefix: json['crashSubjectPrefix'] as String? ?? _defaultCrashSubjectPrefix, feedbackRecipient: json['feedbackRecipient'] as String? ?? _defaultFeedbackRecipient, + feedbackSubjectPrefix: json['feedbackSubjectPrefix'] as String? ?? _defaultFeedbackSubjectPrefix, customFontBytes: json['customFontBytes'] != null ? base64Decode(json['customFontBytes'] as String) : null, fontFamilyName: json['fontFamilyName'] as String? ?? _defaultFontName, appbarIcon: json['appbarIcon'] != null @@ -236,7 +254,9 @@ class ApplicationCustomization { 'appName': appName, 'websiteLink': websiteLink, 'crashRecipient': crashRecipient, + 'crashSubjectPrefix': crashSubjectPrefix, 'feedbackRecipient': feedbackRecipient, + 'feedbackSubjectPrefix': feedbackSubjectPrefix, 'fontFamilyName': fontFamilyName, 'customFontBytes': customFontBytes != null ? base64Encode(customFontBytes!) : null, 'appbarIcon': appbarIcon.toJson(), diff --git a/lib/utils/logger.dart b/lib/utils/logger.dart index 02885427..e4bcf66e 100644 --- a/lib/utils/logger.dart +++ b/lib/utils/logger.dart @@ -257,7 +257,13 @@ class Logger { --------------------------------------------------------- Device Parameters $deviceInfo"""; - return PiMailer(mailRecipients: _mailRecipients).sendMail(subject: _lastError, body: completeMailBody, attachments: [_fullPath!]); + return PiMailer.sendMail( + mailRecipients: _mailRecipients, + subjectPrefix: PrivacyIDEAAuthenticator.currentCustomization?.crashSubjectPrefix, + subject: _lastError, + body: completeMailBody, + attachments: [_fullPath!], + ); } static void clearErrorLog() { diff --git a/lib/utils/pi_mailer.dart b/lib/utils/pi_mailer.dart index 5a56a52d..f0d597e6 100644 --- a/lib/utils/pi_mailer.dart +++ b/lib/utils/pi_mailer.dart @@ -23,24 +23,17 @@ import 'package:flutter_mailer/flutter_mailer.dart'; import '../l10n/app_localizations.dart'; import '../widgets/dialog_widgets/default_dialog.dart'; -import 'app_info_utils.dart'; import 'logger.dart'; import 'view_utils.dart'; class PiMailer { - final Set mailRecipients; - const PiMailer({required this.mailRecipients}); - - static String _mailSubject(String? subject, String? subjectPrefix, bool subjectAppVersion) { - String mailSubject = subjectPrefix != null ? '[$subjectPrefix] ' : ''; - if (subjectAppVersion) mailSubject += '(${InfoUtils.currentVersionString}+${InfoUtils.currentBuildNumber}) '; - mailSubject += '${InfoUtils.appName}'; - if (subject != null) mailSubject += ' >>> $subject'; - return mailSubject; + static String _mailSubject(String subject, String? subjectPrefix, bool subjectAppVersion) { + return subjectPrefix != null ? '$subjectPrefix $subject' : subject; } - Future sendMail({ - String? subject, + static Future sendMail({ + required Set mailRecipients, + required String subject, String? subjectPrefix, bool subjectAppVersion = true, required String body, diff --git a/lib/views/feedback_view/widgets/feedback_send_row.dart b/lib/views/feedback_view/widgets/feedback_send_row.dart index fd3bf644..cc9af394 100644 --- a/lib/views/feedback_view/widgets/feedback_send_row.dart +++ b/lib/views/feedback_view/widgets/feedback_send_row.dart @@ -20,7 +20,6 @@ import 'package:flutter/material.dart'; import 'package:privacyidea_authenticator/mains/main_netknights.dart'; -import 'package:privacyidea_authenticator/utils/globals.dart'; import '../../../l10n/app_localizations.dart'; import '../../../utils/app_info_utils.dart'; @@ -135,9 +134,13 @@ class _FeedbackSendRowState extends State { } String _addDeviceInfoToMail(String feedback) => '$feedback\n\n[${InfoUtils.currentVersionAndBuildNumber}] ${InfoUtils.deviceInfoString}'; - Future _sendMail(String mailText) => globalRef != null - ? PiMailer(mailRecipients: _mailRecipients).sendMail(subjectPrefix: 'Feedback', body: mailText, subjectAppVersion: false) - : Future.value(false); + Future _sendMail(String mailText) => PiMailer.sendMail( + mailRecipients: _mailRecipients, + subjectPrefix: PrivacyIDEAAuthenticator.currentCustomization?.feedbackSubjectPrefix, + subject: '', + body: mailText, + subjectAppVersion: false, + ); Set get _mailRecipients => PrivacyIDEAAuthenticator.currentCustomization != null ? {PrivacyIDEAAuthenticator.currentCustomization!.feedbackRecipient} : {};