From 4c0bfbac5d18f0145749c6b947b37c75bf8c9073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Tue, 30 Jan 2024 11:11:52 +0100 Subject: [PATCH] Re-enable emails on package publishing. (#7439) --- CHANGELOG.md | 1 + app/config/dartlang-pub-dev.yaml | 1 - app/config/dartlang-pub.yaml | 1 - app/lib/package/backend.dart | 6 ++---- app/lib/service/services.dart | 2 +- app/lib/shared/configuration.dart | 17 ----------------- app/lib/shared/configuration.g.dart | 5 ----- app/test/shared/test_data/foo_config.yaml | 1 - 8 files changed, 4 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3c69cb7c4..8d3f641875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Important changes to data models, configuration, and migrations between each AppEngine version, listed here to ease deployment and troubleshooting. ## Next Release (replace with git tag when deployed) + * Note: re-enabled email notification on package published events. ## `20240125t125400-all` * Bumped runtimeVersion to `2024.01.22`. diff --git a/app/config/dartlang-pub-dev.yaml b/app/config/dartlang-pub-dev.yaml index be3b715ac1..b475f60415 100644 --- a/app/config/dartlang-pub-dev.yaml +++ b/app/config/dartlang-pub-dev.yaml @@ -27,7 +27,6 @@ pubSiteAudience: 621485135717-idb8t8nnguphtu2drfn2u4ig7r56rm6n.apps.googleuserco pubServerAudience: 621485135717-082tj8o9vu32lbmquftsolqngk2o13lp.apps.googleusercontent.com externalServiceAudience: https://pub.dev gmailRelayServiceAccount: -gmailRelayImpersonatedGSuiteUser: uploadSignerServiceAccount: package-uploader-signer@dartlang-pub-dev.iam.gserviceaccount.com blockRobots: true productionHosts: diff --git a/app/config/dartlang-pub.yaml b/app/config/dartlang-pub.yaml index 372de0ca23..e7def9c3fc 100644 --- a/app/config/dartlang-pub.yaml +++ b/app/config/dartlang-pub.yaml @@ -30,7 +30,6 @@ pubSiteAudience: 818368855108-e8skaopm5ih5nbb82vhh66k7ft5o7dn3.apps.googleuserco pubServerAudience: 818368855108-ulq5tn5t51ga21hg8jkcavbooaljiasp.apps.googleusercontent.com externalServiceAudience: https://pub.dev gmailRelayServiceAccount: pub-gsuite-gmail-delegatee@dartlang-pub.iam.gserviceaccount.com -gmailRelayImpersonatedGSuiteUser: noreply@pub.dev uploadSignerServiceAccount: package-uploader-signer@dartlang-pub.iam.gserviceaccount.com blockRobots: false productionHosts: diff --git a/app/lib/package/backend.dart b/app/lib/package/backend.dart index 5e87b2eef8..bf45d0ab47 100644 --- a/app/lib/package/backend.dart +++ b/app/lib/package/backend.dart @@ -1128,8 +1128,7 @@ class PackageBackend { newVersion, entities.packageVersionInfo, ...entities.assets, - if (activeConfiguration.isPublishedEmailNotificationEnabled) - outgoingEmail, + outgoingEmail, if (isNew) AuditLogRecord.packageCreated( uploader: agent, @@ -1178,8 +1177,7 @@ class PackageBackend { ) async { try { await Future.wait([ - if (activeConfiguration.isPublishedEmailNotificationEnabled) - emailBackend.trySendOutgoingEmail(outgoingEmail), + emailBackend.trySendOutgoingEmail(outgoingEmail), taskBackend.trackPackage(newVersion.package, updateDependants: true), if (apiExporter != null) apiExporter! diff --git a/app/lib/service/services.dart b/app/lib/service/services.dart index d283836add..81d46d7441 100644 --- a/app/lib/service/services.dart +++ b/app/lib/service/services.dart @@ -96,7 +96,7 @@ Future withServices(FutureOr Function() fn) async { registerDomainVerifier(DomainVerifier()); registerEmailSender( activeConfiguration.gmailRelayServiceAccount != null && - activeConfiguration.gmailRelayImpersonatedGSuiteUser != null + activeConfiguration.isProduction ? createGmailRelaySender( activeConfiguration.gmailRelayServiceAccount!, authClient, diff --git a/app/lib/shared/configuration.dart b/app/lib/shared/configuration.dart index b5e82dab76..12d76201be 100644 --- a/app/lib/shared/configuration.dart +++ b/app/lib/shared/configuration.dart @@ -193,17 +193,6 @@ class Configuration { /// **Optional**, if omitted email sending is disabled. final String? gmailRelayServiceAccount; - /// Email of the GSuite user account to impersonate when sending emails - /// through the gmail SMTP relay. - /// - /// This must be the email for an account within the GSuite used for sending - /// emails. It is important that the gmail SMTP relay is enabled for this - /// GSuite, for configuration see: - /// https://support.google.com/a/answer/176600?hl=en - /// - /// **Optional**, if omitted email sending is disabled. - final String? gmailRelayImpersonatedGSuiteUser; - /// The email of the service account which has access rights to sign upload /// requests. The current service must be able to impersonate this account. /// @@ -295,7 +284,6 @@ class Configuration { required this.pubServerAudience, required this.externalServiceAudience, required this.gmailRelayServiceAccount, - required this.gmailRelayImpersonatedGSuiteUser, required this.uploadSignerServiceAccount, required this.blockRobots, required this.productionHosts, @@ -363,7 +351,6 @@ class Configuration { externalServiceAudience: _fakeExternalAudience, defaultServiceBaseUrl: 'http://localhost:$frontendPort/', gmailRelayServiceAccount: null, // disable email sending - gmailRelayImpersonatedGSuiteUser: null, // disable email sending uploadSignerServiceAccount: null, blockRobots: false, productionHosts: ['localhost'], @@ -415,7 +402,6 @@ class Configuration { externalServiceAudience: _fakeExternalAudience, defaultServiceBaseUrl: primaryApiUri?.toString() ?? 'http://localhost:0/', gmailRelayServiceAccount: null, // disable email sending - gmailRelayImpersonatedGSuiteUser: null, // disable email sending uploadSignerServiceAccount: null, blockRobots: true, productionHosts: ['localhost'], @@ -454,9 +440,6 @@ class Configuration { late final isProduction = projectId == 'dartlang-pub'; late final isNotProduction = !isProduction; late final isStaging = projectId == 'dartlang-pub-dev'; - - /// NOTE: email notification on package published is temporarily disabled. - late final isPublishedEmailNotificationEnabled = isNotProduction; } /// Data structure to describe an admin user. diff --git a/app/lib/shared/configuration.g.dart b/app/lib/shared/configuration.g.dart index e4df638305..bca5fedc43 100644 --- a/app/lib/shared/configuration.g.dart +++ b/app/lib/shared/configuration.g.dart @@ -40,7 +40,6 @@ Configuration _$ConfigurationFromJson(Map json) => $checkedCreate( 'pubServerAudience', 'externalServiceAudience', 'gmailRelayServiceAccount', - 'gmailRelayImpersonatedGSuiteUser', 'uploadSignerServiceAccount', 'blockRobots', 'productionHosts', @@ -101,8 +100,6 @@ Configuration _$ConfigurationFromJson(Map json) => $checkedCreate( $checkedConvert('externalServiceAudience', (v) => v as String?), gmailRelayServiceAccount: $checkedConvert('gmailRelayServiceAccount', (v) => v as String?), - gmailRelayImpersonatedGSuiteUser: $checkedConvert( - 'gmailRelayImpersonatedGSuiteUser', (v) => v as String?), uploadSignerServiceAccount: $checkedConvert( 'uploadSignerServiceAccount', (v) => v as String?), blockRobots: $checkedConvert('blockRobots', (v) => v as bool), @@ -166,8 +163,6 @@ Map _$ConfigurationToJson(Configuration instance) => 'pubServerAudience': instance.pubServerAudience, 'externalServiceAudience': instance.externalServiceAudience, 'gmailRelayServiceAccount': instance.gmailRelayServiceAccount, - 'gmailRelayImpersonatedGSuiteUser': - instance.gmailRelayImpersonatedGSuiteUser, 'uploadSignerServiceAccount': instance.uploadSignerServiceAccount, 'blockRobots': instance.blockRobots, 'productionHosts': instance.productionHosts, diff --git a/app/test/shared/test_data/foo_config.yaml b/app/test/shared/test_data/foo_config.yaml index 044ed0300f..011dfcae91 100644 --- a/app/test/shared/test_data/foo_config.yaml +++ b/app/test/shared/test_data/foo_config.yaml @@ -15,7 +15,6 @@ pubClientAudience: _pubClientAudience pubSiteAudience: 'foo-foo.apps.googleusercontent.com' externalServiceAudience: 'https://pub.dev' gmailRelayServiceAccount: -gmailRelayImpersonatedGSuiteUser: uploadSignerServiceAccount: 'foo@dartlang-pub-dev.iam.gserviceaccount.com' blockRobots: true productionHosts: