Skip to content

smtp_batch: add feature for grouping and templating #2610

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

Lukas-Heindl
Copy link
Contributor

@Lukas-Heindl Lukas-Heindl commented Apr 29, 2025

Like discussed in #2586, here is the thing. I already did some manual testing regarding templating the subject string. For this configured

  1. add extra.my_template_value to the events (I did this with the modify bot for now)
  2. add that key (extra.my_template_value) to the new additional_grouping_keys parameter
  3. use subject: "Prefix {{ extra_my_template_value }}"
  4. activate the templating capabilites for the subject line with templating: {subject: true}

But probably some tests in the test suite will be needed for this (but I'd like to defer this one after the first feedback round)

Any comments?

Maybe issues to discuss:

  • how values get hashed generically with hash_arbitrary
  • passing the template_data along with each mail as a tuple
  • really a warning if jinja2 couldn't be imported? (the user might not want jinja2) -- also whether to add this optional requirement to the requirements.txt?

Also I didn't get the testing environment setup correctly until now, so it would be nice if someone could trigger the pipelines yet already so I can check the outputs regarding code-style.

@Lukas-Heindl
Copy link
Contributor Author

Lukas-Heindl commented Apr 29, 2025

Feel free to have a look, but it will be some time (estimate: 1-2 weeks) until I can have a look at the failing pipelines.
My way to go would be

  1. looking into what makes them fail
    • code style should pass obviously
    • failing tests here might indicate a not fully backwards compatible change
  2. feedback (of course any time, also before/while 1.)
  3. Write additional tests covering the new features

@sebix sebix requested a review from e3rd April 29, 2025 18:55
@sebix sebix added bug Indicates an unexpected problem or unintended behavior feature Indicates new feature requests or new features labels Apr 29, 2025
Copy link
Member

@e3rd e3rd left a comment

Choose a reason for hiding this comment

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

Seems good, thanks! :)


def build_mail(self, mail, send=False, override_to=None):
def build_mail(self, mail, send=False, override_to=None, template_data:dict[str, Any]={}):
Copy link
Member

Choose a reason for hiding this comment

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

Integrate template_data into the Mail dataclass instead of passing tuples.

Add annotations in the new code for the non-trivial objects (they did not exist when I wrote it originally), ex, def build_mail(self, mail: Mail,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior feature Indicates new feature requests or new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants