forked from dart-lang/pub-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Different email senders for different kind of emails. (dart-lang#7431)
- Loading branch information
Showing
2 changed files
with
15 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,23 @@ import 'dart:io'; | |
|
||
import 'urls.dart'; | ||
|
||
const pubDartlangOrgEmail = '[email protected]'; | ||
const _invitesAtPubDev = '[email protected]'; | ||
const _noreplyAtPubDev = '[email protected]'; | ||
final _lenientEmailRegExp = RegExp(r'^\S+@\S+\.\S+$'); | ||
|
||
/// Strict regular expression used in <input type="email" /> | ||
/// https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address | ||
final _strictEmailRegExp = RegExp( | ||
r'''[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$'''); | ||
|
||
final _defaultFrom = EmailAddress( | ||
pubDartlangOrgEmail, | ||
name: 'Dart package site admin', | ||
final _invitesFrom = EmailAddress( | ||
_invitesAtPubDev, | ||
name: 'Dart package site invites', | ||
); | ||
|
||
final _notificationsFrom = EmailAddress( | ||
_noreplyAtPubDev, | ||
name: 'Dart package site notifications', | ||
); | ||
|
||
String _footer(String action) { | ||
|
@@ -178,7 +184,8 @@ For details, go to $url | |
${_footer('package')} | ||
'''; | ||
|
||
return EmailMessage(_defaultFrom, authorizedUploaders, subject, bodyText); | ||
return EmailMessage( | ||
_notificationsFrom, authorizedUploaders, subject, bodyText); | ||
} | ||
|
||
/// Creates the [EmailMessage] that will be sent to users about new invitations | ||
|
@@ -201,7 +208,7 @@ If you don’t want to accept it, simply ignore this email. | |
${_footer('invitation')} | ||
'''; | ||
return EmailMessage( | ||
_defaultFrom, [EmailAddress(invitedEmail)], subject, bodyText); | ||
_invitesFrom, [EmailAddress(invitedEmail)], subject, bodyText); | ||
} | ||
|
||
/// Creates the [EmailMessage] that we be sent on package transfer to a new publisher. | ||
|
@@ -229,5 +236,5 @@ For details, go to $url | |
${_footer('transfer')} | ||
'''; | ||
|
||
return EmailMessage(_defaultFrom, authorizedAdmins, subject, bodyText); | ||
return EmailMessage(_notificationsFrom, authorizedAdmins, subject, bodyText); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,7 +166,7 @@ void main() { | |
EmailAddress('[email protected]') | ||
], | ||
); | ||
expect(message.from.toString(), contains('<noreply@pub.dev>')); | ||
expect(message.from.toString(), contains('@pub.dev')); | ||
expect(message.recipients.map((e) => e.toString()).toList(), [ | ||
'Joe <[email protected]>', | ||
'[email protected]', | ||
|