Skip to content

Adding IAPI email generation to addons#284

Open
jacob6838 wants to merge 191 commits intodevelopfrom
iapi-email-generation-addons
Open

Adding IAPI email generation to addons#284
jacob6838 wants to merge 191 commits intodevelopfrom
iapi-email-generation-addons

Conversation

@jacob6838
Copy link
Copy Markdown
Collaborator

@jacob6838 jacob6838 commented Feb 11, 2026

PR Details

Description

Adding Python API and Addon integration with IAPI Email Generation

  • Adding firmware upgrade failure email generation to IAPI
  • Adding message count email generation to IAPI
  • Updating message-counts addon to make email generation requests to IAPI
  • Updating firmware-upgrade-runner addon to make email generation requests to IAPI
  • Removing python-based email sending capabilities

Before merging, the CDOT DevOps PR needs to be merged and deployed: https://dev.azure.com/SOC-OIT/CDOT/_git/cdot-cv-gcp/pullrequest/131139

Daily Message Counts

image

Firmware Upgrade Failure

image

How Has This Been Tested?

Integration and email generation have been tested in the CDOT Dev environment, for both the message-counts and firmware-upgrade-runner addons.

Local email generation was tested using the smtp4dev docker image (added through the "intersection" docker compose profile).
The specific email generators were tested as follows:

  • firmware upgrade failure: Hitting the IAPI emails/send-firmware-upgrade-failure (POST) endpoint with an HTTP request
  • message-counts: Hitting the IAPI emails/send-message-counts (POST) endpoint with an HTTP request

Types of changes

  • Defect fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that cause existing functionality to change)

Checklist:

  • My changes require new environment variables:
    • I have updated the docker-compose, K8s YAML, and all dependent deployment configuration files.
  • My changes require updates to the documentation:
    • I have updated the documentation accordingly.
  • My changes require updates and/or additions to the unit tests:
    • I have modified/added tests to cover my changes.
  • All existing tests pass.

jacob6838 and others added 30 commits January 6, 2026 10:06
…/api/emails/generators/IntersectionNotificationSummaryEmailGenerator.java

Co-authored-by: Matt Cook <mattheworion.cook@gmail.com>
@jacob6838 jacob6838 requested a review from payneBrandon April 22, 2026 15:09
@payneBrandon
Copy link
Copy Markdown
Collaborator

@drewjj there seems to have been a number of changes since your last review if you wanted to take another look

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Integrates Intersection API (IAPI) email generation for message-count and firmware-upgrade-failure notifications, updating the Python addons to request email sending via IAPI (instead of sending emails directly via SMTP).

Changes:

  • Added new IAPI email request models + generators for Message Counts and Firmware Upgrade Failure emails.
  • Added new /emails/message-counts and /emails/firmware-upgrade-failures endpoints and EmailService methods.
  • Updated addons (count_metric + firmware upgrade runner) and their env/config to use Keycloak service accounts + IAPI email endpoints; removed SMTP-based email sending.

Reviewed changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
services/intersection-api/docs/email_examples/rsu_error_summary_example.html Updates HTML email example content (footer removed).
services/intersection-api/api/src/test/java/us/dot/its/jpo/ode/api/services/EmailServiceTest.java Adds EmailService tests for new email send methods.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/services/EmailService.java Adds EmailService methods for message counts + firmware upgrade failure sends.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/repositories/UserEmailNotificationRepository.java Fixes/clarifies JPQL joins + parameter naming for org/RSU recipient queries.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/models/emails/contents/message_counts/MessageCountRsuItem.java Adds API model for per-RSU counts.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/models/emails/contents/message_counts/MessageCountEmailContents.java Adds API model for message count email request payload.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/models/emails/contents/message_counts/MessageCountCountsItem.java Adds API model for per-message-type counts + diff%.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/models/emails/contents/SupportRequestEmailContents.java Adds OpenAPI schema metadata.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/models/emails/contents/RsuErrorSummaryEmailContents.java Adds OpenAPI schema metadata.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/models/emails/contents/IntersectionNotificationSummaryEmailContents.java Adds OpenAPI schema metadata.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/models/emails/contents/IntersectionNotificationEmailContents.java Adds OpenAPI schema metadata.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/models/emails/contents/FirmwareUpgradeFailureEmailContents.java Adds API model for firmware upgrade failure email request payload.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/models/emails/contents/ApiErrorEmailContents.java Adds OpenAPI schema metadata.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/emails/generators/MessageCountEmailGenerator.java Adds HTML email generator for message count summary emails.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/emails/generators/FirmwareUpgradeFailureEmailGenerator.java Adds HTML email generator for firmware upgrade failure emails.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/controllers/users/UserController.java Import reordering/cleanup.
services/intersection-api/api/src/main/java/us/dot/its/jpo/ode/api/controllers/EmailController.java Adds new email send endpoints for message counts + firmware upgrade failures.
services/common/tests/test_email_api.py Updates tests for firmware upgrade payload key rename.
services/common/email_api.py Updates firmware upgrade failure JSON payload key (error_messagemessage).
services/common/common_environment.py Adds secret flag to suppress logging env var values for secrets.
services/addons/tests/firmware_manager/upgrade_scheduler/conftest.py Removes SMTP env test setup.
services/addons/tests/firmware_manager/upgrade_runner/test_yunex_upgrader.py Adjusts tests to stub send_error_email.
services/addons/tests/firmware_manager/upgrade_runner/conftest.py Adds env vars for upgrade_runner tests (IAPI/Keycloak SA).
services/addons/tests/count_metric/test_daily_emailer.py Updates daily emailer tests to use EmailApi + Keycloak SA flow.
services/addons/tests/count_metric/conftest.py Switches test env setup from SMTP vars to IAPI/Keycloak vars.
services/addons/images/firmware_manager/upgrade_runner/yunex_upgrader.py Captures stack traces and calls updated send_error_email signature.
services/addons/images/firmware_manager/upgrade_runner/upgrader.py Switches from SMTP sending to IAPI EmailApi + Keycloak service account.
services/addons/images/firmware_manager/upgrade_runner/upgrade_runner_environment.py Replaces SMTP env vars with IAPI/Keycloak service-account env vars.
services/addons/images/firmware_manager/upgrade_runner/sample.env Updates sample env to IAPI/Keycloak service-account configuration.
services/addons/images/firmware_manager/upgrade_runner/commsignia_upgrader.py Captures stack traces and calls updated send_error_email signature.
services/addons/images/firmware_manager/requirements.txt Adds python-keycloak dependency.
services/addons/images/count_metric/sample.env Updates sample env to IAPI/Keycloak service-account configuration.
services/addons/images/count_metric/requirements.txt Adds python-keycloak dependency.
services/addons/images/count_metric/daily_emailer.py Replaces SMTP email sending with IAPI EmailApi request.
services/addons/images/count_metric/count_metric_environment.py Replaces SMTP env vars with IAPI/Keycloak service-account env vars.
docker-compose-intersection.yml Changes default SMTP port for intersection_api (smtp4dev alignment).
docker-compose-addons.yml Updates addon env vars to IAPI/Keycloak service accounts; adjusts port mapping for upgrade scheduler.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/common/email_api.py
Comment thread services/addons/images/firmware_manager/upgrade_runner/upgrader.py Outdated
Comment thread services/addons/tests/firmware_manager/upgrade_runner/conftest.py
context.setVariable("content_1", contentBuilder.toString());
context.setVariable("footer_address", "CV-Manager Firmware Upgrade Failure");

String htmlContent = templateEngine.process("emails/email_template", context);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

question: between this class and the message count email generator, we have quite a bit of custom html being injected into the generic template. Would it make sense to have separate email templates for each email type, and then only set the changing values in here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah this is something I debated a lot... I think that is a fair point

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added custom templates for message counts and firmware upgrade failure emails

Copy link
Copy Markdown
Collaborator

@payneBrandon payneBrandon left a comment

Choose a reason for hiding this comment

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

couple questions, but overall looking good

@jacob6838 jacob6838 requested a review from payneBrandon April 27, 2026 19:38
Base automatically changed from iapi-email-generation-python-email-sending to develop April 27, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants