diff --git a/libervia/backend/plugins/plugin_xep_0106.py b/libervia/backend/plugins/plugin_xep_0106.py index f0228bb2..1d9a9d26 100644 --- a/libervia/backend/plugins/plugin_xep_0106.py +++ b/libervia/backend/plugins/plugin_xep_0106.py @@ -61,7 +61,7 @@ class XEP_0106(object): def get_handler(self, client): return XEP_0106_handler() - def escape(self, text): + def escape(self, text) -> str: """Escape text @param text(unicode): text to escape @@ -78,7 +78,7 @@ class XEP_0106(object): escaped.append(c) return "".join(escaped) - def unescape(self, escaped): + def unescape(self, escaped) -> str: """Unescape text @param escaped(unicode): text to unescape diff --git a/libervia/backend/tools/common/email.py b/libervia/backend/tools/common/email.py index efff7143..82cefadd 100644 --- a/libervia/backend/tools/common/email.py +++ b/libervia/backend/tools/common/email.py @@ -20,7 +20,9 @@ """email sending facilities""" +from configparser import ConfigParser from email.mime.text import MIMEText +from twisted.internet import defer from twisted.mail import smtp from libervia.backend.core.constants import Const as C from libervia.backend.tools import config as tools_config @@ -29,16 +31,22 @@ from libervia.backend.core.log import getLogger log = getLogger(__name__) -def send_email(config, to_emails, subject="", body="", from_email=None): - """Send an email using SàT configuration +def send_email( + config: ConfigParser, + to_emails: list[str] | str, + subject: str = "", + body: str = "", + from_email: str | None = None, +) -> defer.Deferred: + """Send an email using Libervia configuration - @param config (ConfigParser): the configuration instance - @param to_emails(list[unicode], unicode): list of recipients + @param config: the configuration instance + @param to_emails: list of recipients if unicode, it will be split to get emails - @param subject(unicode): subject of the message - @param body(unicode): body of the message - @param from_email(unicode): address of the sender - @return (D): same as smtp.sendmail + @param subject: subject of the message + @param body: body of the message + @param from_email: address of the sender + @return:Same as smtp.sendmail. """ if isinstance(to_emails, str): to_emails = to_emails.split()