Skip to content

Commit

Permalink
kaisellgren#74: have Address.toString() to generate 'mailbox' so app …
Browse files Browse the repository at this point in the history
…can override with his own sanitization
  • Loading branch information
tomyeh committed May 13, 2020
1 parent 234290a commit 230ec11
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ packages
.packages
*.iml
.dart_tool
/test/smtpserver.json
/test/smtpserver.json
.DS_Store
7 changes: 7 additions & 0 deletions lib/src/entities/address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ class Address {
String mailAddress;

Address([this.mailAddress, this.name]);

@override
String toString() {
var fromName = name ?? '';
// ToDo base64 fromName (add _IRMetaInformation as argument)
return '$fromName <$mailAddress>';
}
}
4 changes: 2 additions & 2 deletions lib/src/entities/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ class Message {
String html;
List<Attachment> attachments = [];

Iterable<Address> _asAddresses(Iterable<dynamic> as) =>
(as ?? []).map((a) => a is String ? Address(a) : a as Address);
static Iterable<Address> _asAddresses(Iterable<dynamic> adrs) =>
adrs == null ? []: adrs.map((a) => a is String ? Address(a) : a as Address);
}
10 changes: 2 additions & 8 deletions lib/src/smtp/internal_representation/ir_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,8 @@ class _IRHeaderText extends _IRHeader {
}
}

Iterable<String> _addressToString(Iterable<Address> addresses) {
if (addresses == null) return [];
return addresses.map((a) {
var fromName = a.name ?? '';
// ToDo base64 fromName (add _IRMetaInformation as argument)
return '$fromName <${a.mailAddress}>';
});
}
Iterable<String> _addressToString(Iterable<Address> addresses)
=> assress == null ? []: addresses.map((a) => a.toString());

class _IRHeaderAddress extends _IRHeader {
Address _address;
Expand Down

0 comments on commit 230ec11

Please sign in to comment.