From c1ebcfcd61efee19b8df5b3622c475c94a90d0f9 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Sat, 28 Feb 2026 17:27:31 -0500 Subject: [PATCH] add more settings --- bin/nexusbot.dart | 4 ++- lib/controllers/mail_client_controller.dart | 2 ++ lib/models/settings.dart | 2 ++ lib/models/settings.freezed.dart | 34 ++++++++++++--------- lib/models/settings.g.dart | 4 +++ 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/bin/nexusbot.dart b/bin/nexusbot.dart index cdd7e8a..4f65ddb 100644 --- a/bin/nexusbot.dart +++ b/bin/nexusbot.dart @@ -24,11 +24,13 @@ void main(List argsRaw) async { ..addOption("adminName", mandatory: true) ..addOption("adminRoom", mandatory: true) ..addOption("email", mandatory: true) - ..addOption("emailAlias", mandatory: false) ..addOption("mailName", mandatory: true) ..addOption("mailDomain", mandatory: true) ..addOption("smtpPasswordFile", mandatory: true) ..addOption("botPasswordFile", mandatory: true) + ..addOption("emailAlias") + ..addOption("userName") + ..addOption("outgoingPort") ..addOption("inviteTo"); final container = ProviderContainer(); diff --git a/lib/controllers/mail_client_controller.dart b/lib/controllers/mail_client_controller.dart index b5905bf..ab1204c 100644 --- a/lib/controllers/mail_client_controller.dart +++ b/lib/controllers/mail_client_controller.dart @@ -10,6 +10,8 @@ class MailClientController extends AutoDisposeAsyncNotifier { final settings = ref.watch(SettingsController.provider)!; final account = MailAccount.fromManualSettings( email: settings.email, + userName: settings.userName ?? "", + outgoingPort: settings.outgoingPort, name: settings.mailName, incomingHost: settings.mailDomain, outgoingHost: settings.mailDomain, diff --git a/lib/models/settings.dart b/lib/models/settings.dart index 235d4c0..52a2898 100644 --- a/lib/models/settings.dart +++ b/lib/models/settings.dart @@ -20,6 +20,8 @@ abstract class Settings with _$Settings { required String mailDomain, required String smtpPasswordFile, required String botPasswordFile, + String? userName, + @Default(465) int outgoingPort, }) = _Settings; factory Settings.fromJson(Map json) => diff --git a/lib/models/settings.freezed.dart b/lib/models/settings.freezed.dart index 414b06e..e880b47 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 name; String get adminName; String get adminRoom; String get email; String? get emailAlias; String get mailName; String? get inviteTo; String get mailDomain; String get smtpPasswordFile; String get botPasswordFile; + String get socket; Uri get homeserver; Uri get failureUri; Uri get successUri; String get name; String get adminName; String get adminRoom; String get email; String? get emailAlias; String get mailName; String? get inviteTo; String get mailDomain; String get smtpPasswordFile; String get botPasswordFile; String? get userName; int get outgoingPort; /// 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.name, name) || other.name == name)&&(identical(other.adminName, adminName) || other.adminName == adminName)&&(identical(other.adminRoom, adminRoom) || other.adminRoom == adminRoom)&&(identical(other.email, email) || other.email == email)&&(identical(other.emailAlias, emailAlias) || other.emailAlias == emailAlias)&&(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)); + 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.name, name) || other.name == name)&&(identical(other.adminName, adminName) || other.adminName == adminName)&&(identical(other.adminRoom, adminRoom) || other.adminRoom == adminRoom)&&(identical(other.email, email) || other.email == email)&&(identical(other.emailAlias, emailAlias) || other.emailAlias == emailAlias)&&(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.userName, userName) || other.userName == userName)&&(identical(other.outgoingPort, outgoingPort) || other.outgoingPort == outgoingPort)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,socket,homeserver,failureUri,successUri,name,adminName,adminRoom,email,emailAlias,mailName,inviteTo,mailDomain,smtpPasswordFile,botPasswordFile); +int get hashCode => Object.hash(runtimeType,socket,homeserver,failureUri,successUri,name,adminName,adminRoom,email,emailAlias,mailName,inviteTo,mailDomain,smtpPasswordFile,botPasswordFile,userName,outgoingPort); @override String toString() { - return 'Settings(socket: $socket, homeserver: $homeserver, failureUri: $failureUri, successUri: $successUri, name: $name, adminName: $adminName, adminRoom: $adminRoom, email: $email, emailAlias: $emailAlias, mailName: $mailName, inviteTo: $inviteTo, mailDomain: $mailDomain, smtpPasswordFile: $smtpPasswordFile, botPasswordFile: $botPasswordFile)'; + return 'Settings(socket: $socket, homeserver: $homeserver, failureUri: $failureUri, successUri: $successUri, name: $name, adminName: $adminName, adminRoom: $adminRoom, email: $email, emailAlias: $emailAlias, mailName: $mailName, inviteTo: $inviteTo, mailDomain: $mailDomain, smtpPasswordFile: $smtpPasswordFile, botPasswordFile: $botPasswordFile, userName: $userName, outgoingPort: $outgoingPort)'; } @@ -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 name, String adminName, String adminRoom, String email, String? emailAlias, String mailName, String? inviteTo, String mailDomain, String smtpPasswordFile, String botPasswordFile + String socket, Uri homeserver, Uri failureUri, Uri successUri, String name, String adminName, String adminRoom, String email, String? emailAlias, String mailName, String? inviteTo, String mailDomain, String smtpPasswordFile, String botPasswordFile, String? userName, int outgoingPort }); @@ -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? name = null,Object? adminName = null,Object? adminRoom = null,Object? email = null,Object? emailAlias = freezed,Object? mailName = null,Object? inviteTo = freezed,Object? mailDomain = null,Object? smtpPasswordFile = null,Object? botPasswordFile = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? socket = null,Object? homeserver = null,Object? failureUri = null,Object? successUri = null,Object? name = null,Object? adminName = null,Object? adminRoom = null,Object? email = null,Object? emailAlias = freezed,Object? mailName = null,Object? inviteTo = freezed,Object? mailDomain = null,Object? smtpPasswordFile = null,Object? botPasswordFile = null,Object? userName = freezed,Object? outgoingPort = null,}) { 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,7 +82,9 @@ as String,inviteTo: freezed == inviteTo ? _self.inviteTo : inviteTo // ignore: c as String?,mailDomain: null == mailDomain ? _self.mailDomain : mailDomain // ignore: cast_nullable_to_non_nullable 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, +as String,userName: freezed == userName ? _self.userName : userName // ignore: cast_nullable_to_non_nullable +as String?,outgoingPort: null == outgoingPort ? _self.outgoingPort : outgoingPort // ignore: cast_nullable_to_non_nullable +as int, )); } @@ -93,7 +95,7 @@ as String, @JsonSerializable() class _Settings implements Settings { - const _Settings({required this.socket, required this.homeserver, required this.failureUri, required this.successUri, required this.name, required this.adminName, required this.adminRoom, required this.email, required this.emailAlias, required this.mailName, required this.inviteTo, required this.mailDomain, required this.smtpPasswordFile, required this.botPasswordFile}); + const _Settings({required this.socket, required this.homeserver, required this.failureUri, required this.successUri, required this.name, required this.adminName, required this.adminRoom, required this.email, required this.emailAlias, required this.mailName, required this.inviteTo, required this.mailDomain, required this.smtpPasswordFile, required this.botPasswordFile, this.userName, this.outgoingPort = 465}); factory _Settings.fromJson(Map json) => _$SettingsFromJson(json); @override final String socket; @@ -110,6 +112,8 @@ class _Settings implements Settings { @override final String mailDomain; @override final String smtpPasswordFile; @override final String botPasswordFile; +@override final String? userName; +@override@JsonKey() final int outgoingPort; /// Create a copy of Settings /// with the given fields replaced by the non-null parameter values. @@ -124,16 +128,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.name, name) || other.name == name)&&(identical(other.adminName, adminName) || other.adminName == adminName)&&(identical(other.adminRoom, adminRoom) || other.adminRoom == adminRoom)&&(identical(other.email, email) || other.email == email)&&(identical(other.emailAlias, emailAlias) || other.emailAlias == emailAlias)&&(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)); + 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.name, name) || other.name == name)&&(identical(other.adminName, adminName) || other.adminName == adminName)&&(identical(other.adminRoom, adminRoom) || other.adminRoom == adminRoom)&&(identical(other.email, email) || other.email == email)&&(identical(other.emailAlias, emailAlias) || other.emailAlias == emailAlias)&&(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.userName, userName) || other.userName == userName)&&(identical(other.outgoingPort, outgoingPort) || other.outgoingPort == outgoingPort)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,socket,homeserver,failureUri,successUri,name,adminName,adminRoom,email,emailAlias,mailName,inviteTo,mailDomain,smtpPasswordFile,botPasswordFile); +int get hashCode => Object.hash(runtimeType,socket,homeserver,failureUri,successUri,name,adminName,adminRoom,email,emailAlias,mailName,inviteTo,mailDomain,smtpPasswordFile,botPasswordFile,userName,outgoingPort); @override String toString() { - return 'Settings(socket: $socket, homeserver: $homeserver, failureUri: $failureUri, successUri: $successUri, name: $name, adminName: $adminName, adminRoom: $adminRoom, email: $email, emailAlias: $emailAlias, mailName: $mailName, inviteTo: $inviteTo, mailDomain: $mailDomain, smtpPasswordFile: $smtpPasswordFile, botPasswordFile: $botPasswordFile)'; + return 'Settings(socket: $socket, homeserver: $homeserver, failureUri: $failureUri, successUri: $successUri, name: $name, adminName: $adminName, adminRoom: $adminRoom, email: $email, emailAlias: $emailAlias, mailName: $mailName, inviteTo: $inviteTo, mailDomain: $mailDomain, smtpPasswordFile: $smtpPasswordFile, botPasswordFile: $botPasswordFile, userName: $userName, outgoingPort: $outgoingPort)'; } @@ -144,7 +148,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 name, String adminName, String adminRoom, String email, String? emailAlias, String mailName, String? inviteTo, String mailDomain, String smtpPasswordFile, String botPasswordFile + String socket, Uri homeserver, Uri failureUri, Uri successUri, String name, String adminName, String adminRoom, String email, String? emailAlias, String mailName, String? inviteTo, String mailDomain, String smtpPasswordFile, String botPasswordFile, String? userName, int outgoingPort }); @@ -161,7 +165,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? name = null,Object? adminName = null,Object? adminRoom = null,Object? email = null,Object? emailAlias = freezed,Object? mailName = null,Object? inviteTo = freezed,Object? mailDomain = null,Object? smtpPasswordFile = null,Object? botPasswordFile = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? socket = null,Object? homeserver = null,Object? failureUri = null,Object? successUri = null,Object? name = null,Object? adminName = null,Object? adminRoom = null,Object? email = null,Object? emailAlias = freezed,Object? mailName = null,Object? inviteTo = freezed,Object? mailDomain = null,Object? smtpPasswordFile = null,Object? botPasswordFile = null,Object? userName = freezed,Object? outgoingPort = null,}) { 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 @@ -177,7 +181,9 @@ as String,inviteTo: freezed == inviteTo ? _self.inviteTo : inviteTo // ignore: c as String?,mailDomain: null == mailDomain ? _self.mailDomain : mailDomain // ignore: cast_nullable_to_non_nullable 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, +as String,userName: freezed == userName ? _self.userName : userName // ignore: cast_nullable_to_non_nullable +as String?,outgoingPort: null == outgoingPort ? _self.outgoingPort : outgoingPort // ignore: cast_nullable_to_non_nullable +as int, )); } diff --git a/lib/models/settings.g.dart b/lib/models/settings.g.dart index ce83370..3f7c75d 100644 --- a/lib/models/settings.g.dart +++ b/lib/models/settings.g.dart @@ -21,6 +21,8 @@ _Settings _$SettingsFromJson(Map json) => _Settings( mailDomain: json['mailDomain'] as String, smtpPasswordFile: json['smtpPasswordFile'] as String, botPasswordFile: json['botPasswordFile'] as String, + userName: json['userName'] as String?, + outgoingPort: (json['outgoingPort'] as num?)?.toInt() ?? 465, ); Map _$SettingsToJson(_Settings instance) => { @@ -38,4 +40,6 @@ Map _$SettingsToJson(_Settings instance) => { 'mailDomain': instance.mailDomain, 'smtpPasswordFile': instance.smtpPasswordFile, 'botPasswordFile': instance.botPasswordFile, + 'userName': instance.userName, + 'outgoingPort': instance.outgoingPort, };