Coverage for src/backend/InvenTree/plugin/base/mail/mixins.py: 69%
13 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
1"""Plugin mixin class for mails."""
3from django.core.mail import EmailMessage
5from plugin import PluginMixinEnum
6from plugin.helpers import MixinNotImplementedError
9class MailMixin:
10 """Mixin that provides support for processing mails before/after going to the sending/receiving commands.
12 Implementing classes must provide a "process_mail_out" and "process_mail_in" function:
13 """
15 def process_mail_out(self, mail: EmailMessage, *args, **kwargs) -> None:
16 """Function to handle a mail that is going to be send.
18 Must be overridden by plugin.
19 """
20 # Default implementation does not do anything
21 raise MixinNotImplementedError
23 def process_mail_in(self, mail: EmailMessage, *args, **kwargs) -> None:
24 """Function to handle a mail that was received.
26 Must be overridden by plugin.
27 """
28 # Default implementation does not do anything
29 raise MixinNotImplementedError
31 class MixinMeta:
32 """Meta options for this mixin."""
34 MIXIN_NAME = 'Mail'
36 def __init__(self):
37 """Register the mixin."""
38 super().__init__()
39 self.add_mixin(PluginMixinEnum.MAIL, True, __class__)