Skip to content

[Refactor:Notifications] Consolidate Email Formatting#11793

Merged
bmcutler merged 7 commits into
mainfrom
email-footer-normalization
Jun 25, 2025
Merged

[Refactor:Notifications] Consolidate Email Formatting#11793
bmcutler merged 7 commits into
mainfrom
email-footer-normalization

Conversation

@jeffrey-cordero

@jeffrey-cordero jeffrey-cordero commented Jun 23, 2025

Copy link
Copy Markdown
Contributor

Why is this Change Important & Necessary?

Our email format, such as the subject and footer, can be found within the web server and the course notification cron job script, which can be troublesome to maintain as we continue to alter their contents. A more maintainable approach would be to normalize the given footer or subject contents before sending them, and not store redundant content in the master database, as they can be implied from the original subject or the potential term and course. Fixes #11734.

What is the New Behavior?

The subject and footer contents are now calculated within the email cron job script and added to the finalized email before being delivered over the network. You can verify the original email content within the master database (SELECT subject, body FROM emails ORDER by created DESC LIMIT 1; and the finalized email content within the individual logs (/var/local/submitty/logs/emails/mailboxes/<email>/<id>[email protected]).

root@ubuntu:/usr/local/submitty# cat /var/local/submitty/logs/emails/mailboxes/[email protected]/[email protected]
Content-Type: text/plain; charset=utf-8
TO: [email protected]
From: submitty@vagrant
reply-to: do-not-reply@vagrant
Subject: [Submitty sample]: New Announcement: Announcement


An Instructor or Teaching Assistant made an announcement in:
SAMPLE

Announcement

Announcement Content...

Author: Quinn I.
Click here for more info: http://localhost:1511/courses/s25/sample/forum/threads/10

--
NOTE: This is an automated email notification, which is unable to receive replies.
Please refer to the course syllabus for contact information for your teaching staff.
Update your email notification settings for this course here: http://localhost:1511/courses/s25/sample/notifications/settings

root@ubuntu:/usr/local/submitty# cat /var/local/submitty/logs/emails/mailboxes/[email protected]/[email protected]
Content-Type: text/plain; charset=utf-8
TO: [email protected]
From: submitty@vagrant
reply-to: do-not-reply@vagrant
Subject: [Submitty sample] Grade Released: Grades Released Homework


Your grade is now available for Grades Released Homework in course 
SAMPLE.

Click here for more info: http://localhost:1511/courses/s25/sample/gradeable/grades_released_homework

--
NOTE: This is an automated email notification, which is unable to receive replies.
Please refer to the course syllabus for contact information for your teaching staff.
Update your email notification settings for this course here: http://localhost:1511/courses/s25/sample/notifications/settings

Additionally, this pull request resolves the issue of invalid email error logs displayed on the email status page, which currently shows a site error. The current implementation attempts to access the email error via array access, but it's an email entity; thus, the Doctrine getter method should be used.

Before

image

After

image

What steps should a reviewer take to reproduce or test the bug or new feature?

  1. Release an instructor/admin announcement or grade notifications (see [Feature:Notifications] Released grade notification #10358).
  2. Wait for the emails to be automatically released (100 per min. ~ not applicable to grade notifications unless the cron job ran recently), or run python3 /usr/local/submitty/sbin/send_email.py using the submitty_daemon user as many times as needed.
  3. Verify the original and finalized email content using the sources noted above.
  4. For testing the email errors, run UPDATE emails SET error = 'x'; and notice the difference in the email status page. Revert the change via UPDATE emails SET error = '';

Automated Testing & Documentation

Email unit tests have been updated to ignore the footer content.

Other information

N/A

@codecov

codecov Bot commented Jun 23, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 20.78%. Comparing base (cb6ceb2) to head (0918042).
Report is 13 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #11793      +/-   ##
============================================
- Coverage     20.81%   20.78%   -0.04%     
+ Complexity     9115     9111       -4     
============================================
  Files           260      261       +1     
  Lines         34967    34951      -16     
  Branches        460      460              
============================================
- Hits           7280     7266      -14     
+ Misses        27231    27229       -2     
  Partials        456      456              
Flag Coverage Δ
autograder 21.34% <ø> (ø)
js 2.13% <ø> (-0.01%) ⬇️
migrator 100.00% <ø> (ø)
php 19.47% <100.00%> (-0.04%) ⬇️
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 88.88% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeffrey-cordero jeffrey-cordero moved this from Seeking Reviewer to Work in Progress in Submitty Development Jun 23, 2025
@jeffrey-cordero jeffrey-cordero changed the title [Refactor:Notifications] Consolidate Email Footer [Refactor:Notifications] Consolidate Email Content Jun 24, 2025
@jeffrey-cordero jeffrey-cordero changed the title [Refactor:Notifications] Consolidate Email Content [Refactor:Notifications] Consolidate Email Formatting Jun 24, 2025
@jeffrey-cordero jeffrey-cordero moved this from Work in Progress to Seeking Reviewer in Submitty Development Jun 24, 2025
@jeffrey-cordero jeffrey-cordero moved this from Seeking Reviewer to In Review in Submitty Development Jun 24, 2025

@Chriun Chriun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code logic looks sound, functionality works as expected, and unit test passes. Footer is not duplicated in any other places besides send_email.py and is not stored in the database.

image

However, I had some issues with the Email Status twig page where I was not able to access other pages with emails. I will make an issue on this since it should not be related to this PR.

image

@github-project-automation github-project-automation Bot moved this from In Review to Awaiting Maintainer Review in Submitty Development Jun 24, 2025
@bmcutler
bmcutler merged commit d463be9 into main Jun 25, 2025
30 checks passed
@bmcutler
bmcutler deleted the email-footer-normalization branch June 25, 2025 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Consolidate email footer text duplicate

3 participants