From b38745b157c31720125923ab4c02651544b96fa3 Mon Sep 17 00:00:00 2001 From: Kyle Ju Date: Wed, 1 Feb 2023 17:15:49 -0800 Subject: [PATCH] Revert "Create /tasks/email-reviewers in notifier" This reverts commit dc48d2d29c9299e80875f40746f567f13dca3417. --- dispatch.yaml | 3 --- internals/notifier.py | 42 ++++++++---------------------------------- main.py | 1 - notifier.staging.yaml | 4 ---- notifier.yaml | 4 ---- 5 files changed, 8 insertions(+), 46 deletions(-) diff --git a/dispatch.yaml b/dispatch.yaml index 0ef2c014..bb5c2499 100644 --- a/dispatch.yaml +++ b/dispatch.yaml @@ -10,8 +10,5 @@ dispatch: - url: "*/tasks/email-subscribers" service: notifier -- url: "*/tasks/email-reviewers" - service: notifier - - url: "*/*" service: default diff --git a/internals/notifier.py b/internals/notifier.py index cf7cddb0..e247f09c 100644 --- a/internals/notifier.py +++ b/internals/notifier.py @@ -146,12 +146,16 @@ def apply_subscription_rules( return results -def make_email_tasks(fe: FeatureEntry, target_emails: list[str], - is_update: bool = False, changes: Optional[list] = None): +def make_email_tasks(fe: FeatureEntry, is_update: bool=False, + changes: Optional[list]=None): """Return a list of task dicts to notify users of feature changes.""" if changes is None: changes = [] + watchers: list[FeatureOwner] = FeatureOwner.query( + FeatureOwner.watching_all_features == True).fetch(None) + watcher_emails: list[str] = [watcher.email for watcher in watchers] + fe_stages = stage_helpers.get_feature_stages(fe.key.integer_id()) email_html = format_email_body(is_update, fe, fe_stages, changes) @@ -177,7 +181,7 @@ def make_email_tasks(fe: FeatureEntry, target_emails: list[str], 'You are CC\'d on this feature' ) accumulate_reasons( - addr_reasons, target_emails, + addr_reasons, watcher_emails, 'You are watching all feature changes') # There will always be at least one component. @@ -365,37 +369,7 @@ class FeatureChangeHandler(basehandlers.FlaskHandler): # Load feature directly from NDB so as to never get a stale cached copy. fe = FeatureEntry.get_by_id(feature['id']) if fe and (is_update and len(changes) or not is_update): - watchers: list[FeatureOwner] = FeatureOwner.query( - FeatureOwner.watching_all_features == True).fetch(None) - watcher_emails: list[str] = [watcher.email for watcher in watchers] - - email_tasks = make_email_tasks(fe, target_emails=watcher_emails, - is_update=is_update, changes=changes) - send_emails(email_tasks) - - return {'message': 'Done'} - - -class FeatureReviewHandler(basehandlers.FlaskHandler): - """This task handles feature review requests by making email tasks.""" - - IS_INTERNAL_HANDLER = True - - def process_post_data(self, **kwargs): - self.require_task_header() - - feature = self.get_param('feature') - gate_type = self.get_param('gate_type') - changes = self.get_param('changes', required=False) or [] - - logging.info('Starting to notify reviewers for feature %s', - repr(feature)[:settings.MAX_LOG_LINE]) - - fe = FeatureEntry.get_by_id(feature['id']) - if fe: - approvers = approval_defs.get_approvers(gate_type) - email_tasks = make_email_tasks(fe, target_emails=approvers, - is_update=True, changes=changes) + email_tasks = make_email_tasks(fe, is_update=is_update, changes=changes) send_emails(email_tasks) return {'message': 'Done'} diff --git a/main.py b/main.py index 4aba0001..1bcd9435 100644 --- a/main.py +++ b/main.py @@ -236,7 +236,6 @@ internals_routes: list[Route] = [ Route('/tasks/email-subscribers', notifier.FeatureChangeHandler), Route('/tasks/detect-intent', detect_intent.IntentEmailHandler), - Route('/tasks/email-reviewers', notifier.FeatureReviewHandler), Route('/admin/schema_migration_delete_entities', schema_migration.DeleteNewEntities), diff --git a/notifier.staging.yaml b/notifier.staging.yaml index e954105c..c8cd3b3f 100644 --- a/notifier.staging.yaml +++ b/notifier.staging.yaml @@ -10,10 +10,6 @@ handlers: script: auto # Header checks prevent raw access to this handler. Tasks have headers. -- url: /tasks/email-reviewers - script: auto - # Header checks prevent raw access to this handler. Tasks have headers. - app_engine_apis: true # Set up VPC Access Connector for Redis. diff --git a/notifier.yaml b/notifier.yaml index a05901a3..4b6297fc 100644 --- a/notifier.yaml +++ b/notifier.yaml @@ -10,10 +10,6 @@ handlers: script: auto # Header checks prevent raw access to this handler. Tasks have headers. -- url: /tasks/email-reviewers - script: auto - # Header checks prevent raw access to this handler. Tasks have headers. - app_engine_apis: true # Set up VPC Access Connector for Redis in prod.