diff --git a/bin/nexusbot.dart b/bin/nexusbot.dart index 3b0e170..a6d1d31 100644 --- a/bin/nexusbot.dart +++ b/bin/nexusbot.dart @@ -28,6 +28,9 @@ void main(List argsRaw) async { ..addOption("smtpPasswordFile", mandatory: true) ..addOption("botPasswordFile", mandatory: true) ..addOption("mailUsername", mandatory: true) + ..addOption("subject", mandatory: true) + ..addOption("markdown", mandatory: true) + ..addOption("plainText") ..addOption("inviteTo"); final container = ProviderContainer(); @@ -99,7 +102,7 @@ void main(List argsRaw) async { .read(MailClientController.provider.notifier) .send( plainText: replace(settings.plainText), - markdown: replace(settings.markdown), + markdown: replace(settings.markdown ?? settings.plainText), subject: settings.subject, to: registration.email, ); diff --git a/lib/models/settings.dart b/lib/models/settings.dart index bc09ba1..ea65f0f 100644 --- a/lib/models/settings.dart +++ b/lib/models/settings.dart @@ -20,9 +20,9 @@ abstract class Settings with _$Settings { required String smtpPasswordFile, required String botPasswordFile, required String mailUsername, - required String plainText, required String subject, - required String markdown, + required String plainText, + String? markdown, }) = _Settings; factory Settings.fromJson(Map json) => diff --git a/lib/models/settings.freezed.dart b/lib/models/settings.freezed.dart index 36c6a2b..9cf52f3 100644 --- a/lib/models/settings.freezed.dart +++ b/lib/models/settings.freezed.dart @@ -16,7 +16,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$Settings { - String get socket; Uri get homeserver; Uri get failureUri; Uri get successUri; String get username; String get adminName; String get adminRoom; String get email; String get mailName; String? get inviteTo; String get mailDomain; String get smtpPasswordFile; String get botPasswordFile; String get mailUsername; String get plainText; String get subject; String get markdown; + String get socket; Uri get homeserver; Uri get failureUri; Uri get successUri; String get username; String get adminName; String get adminRoom; String get email; String get mailName; String? get inviteTo; String get mailDomain; String get smtpPasswordFile; String get botPasswordFile; String get mailUsername; String get subject; String get plainText; String? get markdown; /// Create a copy of Settings /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -29,16 +29,16 @@ $SettingsCopyWith get copyWith => _$SettingsCopyWithImpl(thi @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is Settings&&(identical(other.socket, socket) || other.socket == socket)&&(identical(other.homeserver, homeserver) || other.homeserver == homeserver)&&(identical(other.failureUri, failureUri) || other.failureUri == failureUri)&&(identical(other.successUri, successUri) || other.successUri == successUri)&&(identical(other.username, username) || other.username == username)&&(identical(other.adminName, adminName) || other.adminName == adminName)&&(identical(other.adminRoom, adminRoom) || other.adminRoom == adminRoom)&&(identical(other.email, email) || other.email == email)&&(identical(other.mailName, mailName) || other.mailName == mailName)&&(identical(other.inviteTo, inviteTo) || other.inviteTo == inviteTo)&&(identical(other.mailDomain, mailDomain) || other.mailDomain == mailDomain)&&(identical(other.smtpPasswordFile, smtpPasswordFile) || other.smtpPasswordFile == smtpPasswordFile)&&(identical(other.botPasswordFile, botPasswordFile) || other.botPasswordFile == botPasswordFile)&&(identical(other.mailUsername, mailUsername) || other.mailUsername == mailUsername)&&(identical(other.plainText, plainText) || other.plainText == plainText)&&(identical(other.subject, subject) || other.subject == subject)&&(identical(other.markdown, markdown) || other.markdown == markdown)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is Settings&&(identical(other.socket, socket) || other.socket == socket)&&(identical(other.homeserver, homeserver) || other.homeserver == homeserver)&&(identical(other.failureUri, failureUri) || other.failureUri == failureUri)&&(identical(other.successUri, successUri) || other.successUri == successUri)&&(identical(other.username, username) || other.username == username)&&(identical(other.adminName, adminName) || other.adminName == adminName)&&(identical(other.adminRoom, adminRoom) || other.adminRoom == adminRoom)&&(identical(other.email, email) || other.email == email)&&(identical(other.mailName, mailName) || other.mailName == mailName)&&(identical(other.inviteTo, inviteTo) || other.inviteTo == inviteTo)&&(identical(other.mailDomain, mailDomain) || other.mailDomain == mailDomain)&&(identical(other.smtpPasswordFile, smtpPasswordFile) || other.smtpPasswordFile == smtpPasswordFile)&&(identical(other.botPasswordFile, botPasswordFile) || other.botPasswordFile == botPasswordFile)&&(identical(other.mailUsername, mailUsername) || other.mailUsername == mailUsername)&&(identical(other.subject, subject) || other.subject == subject)&&(identical(other.plainText, plainText) || other.plainText == plainText)&&(identical(other.markdown, markdown) || other.markdown == markdown)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,socket,homeserver,failureUri,successUri,username,adminName,adminRoom,email,mailName,inviteTo,mailDomain,smtpPasswordFile,botPasswordFile,mailUsername,plainText,subject,markdown); +int get hashCode => Object.hash(runtimeType,socket,homeserver,failureUri,successUri,username,adminName,adminRoom,email,mailName,inviteTo,mailDomain,smtpPasswordFile,botPasswordFile,mailUsername,subject,plainText,markdown); @override String toString() { - return 'Settings(socket: $socket, homeserver: $homeserver, failureUri: $failureUri, successUri: $successUri, username: $username, adminName: $adminName, adminRoom: $adminRoom, email: $email, mailName: $mailName, inviteTo: $inviteTo, mailDomain: $mailDomain, smtpPasswordFile: $smtpPasswordFile, botPasswordFile: $botPasswordFile, mailUsername: $mailUsername, plainText: $plainText, subject: $subject, markdown: $markdown)'; + return 'Settings(socket: $socket, homeserver: $homeserver, failureUri: $failureUri, successUri: $successUri, username: $username, adminName: $adminName, adminRoom: $adminRoom, email: $email, mailName: $mailName, inviteTo: $inviteTo, mailDomain: $mailDomain, smtpPasswordFile: $smtpPasswordFile, botPasswordFile: $botPasswordFile, mailUsername: $mailUsername, subject: $subject, plainText: $plainText, markdown: $markdown)'; } @@ -49,7 +49,7 @@ abstract mixin class $SettingsCopyWith<$Res> { factory $SettingsCopyWith(Settings value, $Res Function(Settings) _then) = _$SettingsCopyWithImpl; @useResult $Res call({ - String socket, Uri homeserver, Uri failureUri, Uri successUri, String username, String adminName, String adminRoom, String email, String mailName, String? inviteTo, String mailDomain, String smtpPasswordFile, String botPasswordFile, String mailUsername, String plainText, String subject, String markdown + String socket, Uri homeserver, Uri failureUri, Uri successUri, String username, String adminName, String adminRoom, String email, String mailName, String? inviteTo, String mailDomain, String smtpPasswordFile, String botPasswordFile, String mailUsername, String subject, String plainText, String? markdown }); @@ -66,7 +66,7 @@ class _$SettingsCopyWithImpl<$Res> /// Create a copy of Settings /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? socket = null,Object? homeserver = null,Object? failureUri = null,Object? successUri = null,Object? username = null,Object? adminName = null,Object? adminRoom = null,Object? email = null,Object? mailName = null,Object? inviteTo = freezed,Object? mailDomain = null,Object? smtpPasswordFile = null,Object? botPasswordFile = null,Object? mailUsername = null,Object? plainText = null,Object? subject = null,Object? markdown = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? socket = null,Object? homeserver = null,Object? failureUri = null,Object? successUri = null,Object? username = null,Object? adminName = null,Object? adminRoom = null,Object? email = null,Object? mailName = null,Object? inviteTo = freezed,Object? mailDomain = null,Object? smtpPasswordFile = null,Object? botPasswordFile = null,Object? mailUsername = null,Object? subject = null,Object? plainText = null,Object? markdown = freezed,}) { return _then(_self.copyWith( socket: null == socket ? _self.socket : socket // ignore: cast_nullable_to_non_nullable as String,homeserver: null == homeserver ? _self.homeserver : homeserver // ignore: cast_nullable_to_non_nullable @@ -82,10 +82,10 @@ as String?,mailDomain: null == mailDomain ? _self.mailDomain : mailDomain // ign as String,smtpPasswordFile: null == smtpPasswordFile ? _self.smtpPasswordFile : smtpPasswordFile // ignore: cast_nullable_to_non_nullable as String,botPasswordFile: null == botPasswordFile ? _self.botPasswordFile : botPasswordFile // ignore: cast_nullable_to_non_nullable as String,mailUsername: null == mailUsername ? _self.mailUsername : mailUsername // ignore: cast_nullable_to_non_nullable -as String,plainText: null == plainText ? _self.plainText : plainText // ignore: cast_nullable_to_non_nullable as String,subject: null == subject ? _self.subject : subject // ignore: cast_nullable_to_non_nullable -as String,markdown: null == markdown ? _self.markdown : markdown // ignore: cast_nullable_to_non_nullable -as String, +as String,plainText: null == plainText ? _self.plainText : plainText // ignore: cast_nullable_to_non_nullable +as String,markdown: freezed == markdown ? _self.markdown : markdown // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -96,7 +96,7 @@ as String, @JsonSerializable() class _Settings implements Settings { - const _Settings({required this.socket, required this.homeserver, required this.failureUri, required this.successUri, required this.username, required this.adminName, required this.adminRoom, required this.email, required this.mailName, required this.inviteTo, required this.mailDomain, required this.smtpPasswordFile, required this.botPasswordFile, required this.mailUsername, required this.plainText, required this.subject, required this.markdown}); + const _Settings({required this.socket, required this.homeserver, required this.failureUri, required this.successUri, required this.username, required this.adminName, required this.adminRoom, required this.email, required this.mailName, required this.inviteTo, required this.mailDomain, required this.smtpPasswordFile, required this.botPasswordFile, required this.mailUsername, required this.subject, required this.plainText, this.markdown}); factory _Settings.fromJson(Map json) => _$SettingsFromJson(json); @override final String socket; @@ -113,9 +113,9 @@ class _Settings implements Settings { @override final String smtpPasswordFile; @override final String botPasswordFile; @override final String mailUsername; -@override final String plainText; @override final String subject; -@override final String markdown; +@override final String plainText; +@override final String? markdown; /// Create a copy of Settings /// with the given fields replaced by the non-null parameter values. @@ -130,16 +130,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _Settings&&(identical(other.socket, socket) || other.socket == socket)&&(identical(other.homeserver, homeserver) || other.homeserver == homeserver)&&(identical(other.failureUri, failureUri) || other.failureUri == failureUri)&&(identical(other.successUri, successUri) || other.successUri == successUri)&&(identical(other.username, username) || other.username == username)&&(identical(other.adminName, adminName) || other.adminName == adminName)&&(identical(other.adminRoom, adminRoom) || other.adminRoom == adminRoom)&&(identical(other.email, email) || other.email == email)&&(identical(other.mailName, mailName) || other.mailName == mailName)&&(identical(other.inviteTo, inviteTo) || other.inviteTo == inviteTo)&&(identical(other.mailDomain, mailDomain) || other.mailDomain == mailDomain)&&(identical(other.smtpPasswordFile, smtpPasswordFile) || other.smtpPasswordFile == smtpPasswordFile)&&(identical(other.botPasswordFile, botPasswordFile) || other.botPasswordFile == botPasswordFile)&&(identical(other.mailUsername, mailUsername) || other.mailUsername == mailUsername)&&(identical(other.plainText, plainText) || other.plainText == plainText)&&(identical(other.subject, subject) || other.subject == subject)&&(identical(other.markdown, markdown) || other.markdown == markdown)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Settings&&(identical(other.socket, socket) || other.socket == socket)&&(identical(other.homeserver, homeserver) || other.homeserver == homeserver)&&(identical(other.failureUri, failureUri) || other.failureUri == failureUri)&&(identical(other.successUri, successUri) || other.successUri == successUri)&&(identical(other.username, username) || other.username == username)&&(identical(other.adminName, adminName) || other.adminName == adminName)&&(identical(other.adminRoom, adminRoom) || other.adminRoom == adminRoom)&&(identical(other.email, email) || other.email == email)&&(identical(other.mailName, mailName) || other.mailName == mailName)&&(identical(other.inviteTo, inviteTo) || other.inviteTo == inviteTo)&&(identical(other.mailDomain, mailDomain) || other.mailDomain == mailDomain)&&(identical(other.smtpPasswordFile, smtpPasswordFile) || other.smtpPasswordFile == smtpPasswordFile)&&(identical(other.botPasswordFile, botPasswordFile) || other.botPasswordFile == botPasswordFile)&&(identical(other.mailUsername, mailUsername) || other.mailUsername == mailUsername)&&(identical(other.subject, subject) || other.subject == subject)&&(identical(other.plainText, plainText) || other.plainText == plainText)&&(identical(other.markdown, markdown) || other.markdown == markdown)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,socket,homeserver,failureUri,successUri,username,adminName,adminRoom,email,mailName,inviteTo,mailDomain,smtpPasswordFile,botPasswordFile,mailUsername,plainText,subject,markdown); +int get hashCode => Object.hash(runtimeType,socket,homeserver,failureUri,successUri,username,adminName,adminRoom,email,mailName,inviteTo,mailDomain,smtpPasswordFile,botPasswordFile,mailUsername,subject,plainText,markdown); @override String toString() { - return 'Settings(socket: $socket, homeserver: $homeserver, failureUri: $failureUri, successUri: $successUri, username: $username, adminName: $adminName, adminRoom: $adminRoom, email: $email, mailName: $mailName, inviteTo: $inviteTo, mailDomain: $mailDomain, smtpPasswordFile: $smtpPasswordFile, botPasswordFile: $botPasswordFile, mailUsername: $mailUsername, plainText: $plainText, subject: $subject, markdown: $markdown)'; + return 'Settings(socket: $socket, homeserver: $homeserver, failureUri: $failureUri, successUri: $successUri, username: $username, adminName: $adminName, adminRoom: $adminRoom, email: $email, mailName: $mailName, inviteTo: $inviteTo, mailDomain: $mailDomain, smtpPasswordFile: $smtpPasswordFile, botPasswordFile: $botPasswordFile, mailUsername: $mailUsername, subject: $subject, plainText: $plainText, markdown: $markdown)'; } @@ -150,7 +150,7 @@ abstract mixin class _$SettingsCopyWith<$Res> implements $SettingsCopyWith<$Res> factory _$SettingsCopyWith(_Settings value, $Res Function(_Settings) _then) = __$SettingsCopyWithImpl; @override @useResult $Res call({ - String socket, Uri homeserver, Uri failureUri, Uri successUri, String username, String adminName, String adminRoom, String email, String mailName, String? inviteTo, String mailDomain, String smtpPasswordFile, String botPasswordFile, String mailUsername, String plainText, String subject, String markdown + String socket, Uri homeserver, Uri failureUri, Uri successUri, String username, String adminName, String adminRoom, String email, String mailName, String? inviteTo, String mailDomain, String smtpPasswordFile, String botPasswordFile, String mailUsername, String subject, String plainText, String? markdown }); @@ -167,7 +167,7 @@ class __$SettingsCopyWithImpl<$Res> /// Create a copy of Settings /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? socket = null,Object? homeserver = null,Object? failureUri = null,Object? successUri = null,Object? username = null,Object? adminName = null,Object? adminRoom = null,Object? email = null,Object? mailName = null,Object? inviteTo = freezed,Object? mailDomain = null,Object? smtpPasswordFile = null,Object? botPasswordFile = null,Object? mailUsername = null,Object? plainText = null,Object? subject = null,Object? markdown = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? socket = null,Object? homeserver = null,Object? failureUri = null,Object? successUri = null,Object? username = null,Object? adminName = null,Object? adminRoom = null,Object? email = null,Object? mailName = null,Object? inviteTo = freezed,Object? mailDomain = null,Object? smtpPasswordFile = null,Object? botPasswordFile = null,Object? mailUsername = null,Object? subject = null,Object? plainText = null,Object? markdown = freezed,}) { return _then(_Settings( socket: null == socket ? _self.socket : socket // ignore: cast_nullable_to_non_nullable as String,homeserver: null == homeserver ? _self.homeserver : homeserver // ignore: cast_nullable_to_non_nullable @@ -183,10 +183,10 @@ as String?,mailDomain: null == mailDomain ? _self.mailDomain : mailDomain // ign as String,smtpPasswordFile: null == smtpPasswordFile ? _self.smtpPasswordFile : smtpPasswordFile // ignore: cast_nullable_to_non_nullable as String,botPasswordFile: null == botPasswordFile ? _self.botPasswordFile : botPasswordFile // ignore: cast_nullable_to_non_nullable as String,mailUsername: null == mailUsername ? _self.mailUsername : mailUsername // ignore: cast_nullable_to_non_nullable -as String,plainText: null == plainText ? _self.plainText : plainText // ignore: cast_nullable_to_non_nullable as String,subject: null == subject ? _self.subject : subject // ignore: cast_nullable_to_non_nullable -as String,markdown: null == markdown ? _self.markdown : markdown // ignore: cast_nullable_to_non_nullable -as String, +as String,plainText: null == plainText ? _self.plainText : plainText // ignore: cast_nullable_to_non_nullable +as String,markdown: freezed == markdown ? _self.markdown : markdown // ignore: cast_nullable_to_non_nullable +as String?, )); } diff --git a/lib/models/settings.g.dart b/lib/models/settings.g.dart index 7749fc4..e6549a6 100644 --- a/lib/models/settings.g.dart +++ b/lib/models/settings.g.dart @@ -21,9 +21,9 @@ _Settings _$SettingsFromJson(Map json) => _Settings( smtpPasswordFile: json['smtpPasswordFile'] as String, botPasswordFile: json['botPasswordFile'] as String, mailUsername: json['mailUsername'] as String, - plainText: json['plainText'] as String, subject: json['subject'] as String, - markdown: json['markdown'] as String, + plainText: json['plainText'] as String, + markdown: json['markdown'] as String?, ); Map _$SettingsToJson(_Settings instance) => { @@ -41,7 +41,7 @@ Map _$SettingsToJson(_Settings instance) => { 'smtpPasswordFile': instance.smtpPasswordFile, 'botPasswordFile': instance.botPasswordFile, 'mailUsername': instance.mailUsername, - 'plainText': instance.plainText, 'subject': instance.subject, + 'plainText': instance.plainText, 'markdown': instance.markdown, };