Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the origin trial display name in trial extension emails #4679

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions internals/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,21 +840,22 @@ class OTExtensionApprovedHandler(basehandlers.FlaskHandler):
def process_post_data(self, **kwargs):
self.require_task_header()
feature = self.get_param('feature')
if feature is None:
self.abort(400, 'No feature provided.')
gate_id = self.get_param('gate_id')
if gate_id is None:
self.abort(400, 'Extension gate ID not provided.')
requester_email = self.get_param('requester_email')
if not requester_email:
self.abort(400, 'Extension requester\'s email address not provided.')
Comment on lines -843 to -850
Copy link
Collaborator Author

@DanielRyanSmith DanielRyanSmith Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These abort statements were unnecessary, since the get_param method contains an abort statement in the event the parameter is not provided.

ot_display_name = self.get_param('ot_display_name')
DanielRyanSmith marked this conversation as resolved.
Show resolved Hide resolved
logging.info('Starting to notify about successful origin trial extension.')
send_emails([self.build_email(feature, requester_email, gate_id)])
send_emails([self.build_email(
feature, requester_email, gate_id, ot_display_name)])

return {'message': 'OK'}

def build_email(
self, feature: FeatureEntry, requester_email: str, gate_id: int):
self,
feature: FeatureEntry,
requester_email: str,
gate_id: int,
ot_display_name: str
):
body_data = {
'feature': feature,
'id': feature['id'],
Expand All @@ -866,8 +867,8 @@ def build_email(
return {
'to': requester_email,
'cc': [OT_SUPPORT_EMAIL],
'subject': ('Origin trial extension approved and ready to be initiated: '
f'{feature["name"]}'),
'subject': ('Origin trial extension approved and ready to be '
f'initiated: {ot_display_name}'),
'reply_to': None,
'html': body,
}
Expand Down
14 changes: 11 additions & 3 deletions internals/notifier_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
from typing import TYPE_CHECKING
import settings
from api import converters
Expand Down Expand Up @@ -211,13 +212,20 @@ def send_ot_creation_notification(stage: Stage):
def send_trial_extension_approved_notification(
fe: 'FeatureEntry', stage: Stage, gate_id: int) -> None:
"""Notify that a trial extension is ready to be finalized."""
# If we don't have an OT owner email, don't send the email out.
# This should always be set, and is collected during the extension request.
if not stage.ot_owner_email:
# If we don't have an OT owner email or stage ID, don't send the email out.
# These should always be set, and are collected during the extension request.
if not stage.ot_owner_email or not stage.ot_stage_id:
return

ot_stage: Stage|None = Stage.get_by_id(stage.ot_stage_id)
if ot_stage is None:
logging.error('No origin trial stage found for given OT stage ID',
stage.ot_stage_id)
return

params = {
'feature': converters.feature_entry_to_json_verbose(fe),
'ot_display_name': ot_stage.ot_display_name,
'requester_email': stage.ot_owner_email,
'gate_id': gate_id,
}
Expand Down
8 changes: 5 additions & 3 deletions internals/notifier_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,8 @@ class OTExtensionApprovedHandlerTest(testing_config.CustomTestCase):
def setUp(self):
self.feature = FeatureEntry(
id=1, name='A feature', summary='summary', category=1)
self.ot_stage = Stage(id=2, feature_id=1, stage_type=150)
self.ot_stage = Stage(id=2, feature_id=1, stage_type=150,
ot_display_name='OT Display Name')
self.extension_stage = Stage(
feature_id=1, ot_stage_id=2, stage_type=151,
milestones=MilestoneSet(desktop_last=106),
Expand All @@ -1150,12 +1151,13 @@ def test_make_extension_approved_email(self):
handler = notifier.OTExtensionApprovedHandler()
email_task = handler.build_email(feature_dict,
self.extension_stage.ot_owner_email,
self.extension_gate.key.integer_id())
self.extension_gate.key.integer_id(),
self.ot_stage.ot_display_name)
# TESTDATA.make_golden(email_task['html'], 'test_make_extension_approved_email.html')
self.assertEqual(
email_task['subject'],
('Origin trial extension approved and ready to be initiated: '
'A feature'))
'OT Display Name'))
self.assertEqual(email_task['html'],
TESTDATA['test_make_extension_approved_email.html'])

Expand Down
Loading