law.notification

law.notification#

Notification functions.

notify_mail(title: str, message: str, recipient: str | None = None, sender: str | None = None, smtp_host: str | None = None, smtp_port: int | None = None, **kwargs) bool[source]#

Sends a notification mail with a title and a string message. recipient, sender, smtp_host and smtp_port default to the configuration values in the [notifications] section. When recipient or sender are not set, a warning is issued and False is returned. Otherwise, the result of util.send_mail() is returned.

notify_custom(title: str, content: dict[str, Any], notify_func: Callable[[str, dict[str, Any]], Any] | str | None = None, **kwargs) bool[source]#

Sends a notification with title and content using a custom notify_func. When notify_func is empty, the configuration value “custom_func” in the [notifications] section is used. When it is a string (which it will be when obtained from the config), it should have the format "module.id.func". The function is then imported and called with the title and message. True is returned when the notification was sent successfully, False otherwise.