Files
sharedinbox/lib/core/models/account.dart
T
Thomas Güttler 8d268f1165 Implement multi-account search and improve repository fakes
- Extended search to support global queries across all accounts.
- Updated SearchScreen to handle optional account context and unified results.
- Centralized mailbox comparison logic in Mailbox model.
- Added copyWith to Account model.
- Fixed race conditions and incorrect overrides in unit, widget, and integration tests.
- Reached 80% unit test coverage.
2026-05-08 01:01:18 +02:00

101 lines
2.9 KiB
Dart

enum AccountType { imap, jmap }
class Account {
final String id;
final String displayName;
final String email;
final AccountType type;
// Used when type == AccountType.imap
final String imapHost;
final int imapPort;
final bool imapSsl;
final String smtpHost;
final int smtpPort;
final bool smtpSsl;
/// ManageSieve host (RFC 5804). Empty falls back to [imapHost].
/// Only consulted when [type] == AccountType.imap.
final String manageSieveHost;
final int manageSievePort;
final bool manageSieveSsl;
/// Tri-state result of the post-save ManageSieve probe.
/// null = not probed yet (treat as available; show UI),
/// true = probe succeeded,
/// false = probe failed (hide ManageSieve UI for this account).
final bool? manageSieveAvailable;
// Used when type == AccountType.jmap
final String? jmapUrl;
/// Login username for IMAP/SMTP/JMAP. Empty means fall back to [email],
/// then to the local part of [email] (the part before '@').
final String username;
/// When true, raw protocol traffic is captured and written to the sync log.
/// Never enable in production — logs contain sensitive data even after
/// credential redaction.
final bool verbose;
const Account({
required this.id,
required this.displayName,
required this.email,
this.username = '',
this.type = AccountType.imap,
this.imapHost = '',
this.imapPort = 993,
this.imapSsl = true,
this.smtpHost = '',
this.smtpPort = 465,
this.smtpSsl = true,
this.manageSieveHost = '',
this.manageSievePort = 4190,
this.manageSieveSsl = true,
this.manageSieveAvailable,
this.jmapUrl,
this.verbose = false,
});
Account copyWith({
String? id,
String? displayName,
String? email,
String? username,
AccountType? type,
String? imapHost,
int? imapPort,
bool? imapSsl,
String? smtpHost,
int? smtpPort,
bool? smtpSsl,
String? manageSieveHost,
int? manageSievePort,
bool? manageSieveSsl,
bool? manageSieveAvailable,
String? jmapUrl,
bool? verbose,
}) {
return Account(
id: id ?? this.id,
displayName: displayName ?? this.displayName,
email: email ?? this.email,
username: username ?? this.username,
type: type ?? this.type,
imapHost: imapHost ?? this.imapHost,
imapPort: imapPort ?? this.imapPort,
imapSsl: imapSsl ?? this.imapSsl,
smtpHost: smtpHost ?? this.smtpHost,
smtpPort: smtpPort ?? this.smtpPort,
smtpSsl: smtpSsl ?? this.smtpSsl,
manageSieveHost: manageSieveHost ?? this.manageSieveHost,
manageSievePort: manageSievePort ?? this.manageSievePort,
manageSieveSsl: manageSieveSsl ?? this.manageSieveSsl,
manageSieveAvailable: manageSieveAvailable ?? this.manageSieveAvailable,
jmapUrl: jmapUrl ?? this.jmapUrl,
verbose: verbose ?? this.verbose,
);
}
}