Skip to content
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

fix: Email methods has been renamed #1395

Merged
merged 4 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/viur/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def setup(modules: ModuleType | object, render: ModuleType | object = None, de
and (not conf.instance.is_dev_server or conf.debug.dev_server_cloud_logging)):
from viur.core import email
try:
email.sendEMailToAdmins(
email.send_email_to_admins(
"Debug mode enabled",
"ViUR just started a new Instance with call tracing enabled! This might log sensitive information!"
)
Expand Down
7 changes: 4 additions & 3 deletions src/viur/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ class Email(ConfigType):

transport_class: "EmailTransport" = None
"""EmailTransport instance that actually delivers the email using the service provider
of choice. See email.py for more details
of choice. See :module:`core.email` for more details
"""

send_from_local_development_server: bool = False
Expand All @@ -545,7 +545,7 @@ class Email(ConfigType):

recipient_override: str | list[str] | t.Callable[[], str | list[str]] | t.Literal[False] = None
"""If set, all outgoing emails will be sent to this address
(overriding the 'dests'-parameter in email.sendEmail)
(overriding the 'dests'-parameter in :meth:`core.email.send_email`)
"""

sender_default: str = f"viur@{_project_id}.appspotmail.com"
Expand All @@ -558,7 +558,8 @@ class Email(ConfigType):
"""If set, this sender will be used, regardless of what the templates advertise as sender"""

admin_recipients: str | list[str] | t.Callable[[], str | list[str]] = None
"""Sets recipients for mails send with email.sendEMailToAdmins. If not set, all root users will be used."""
"""Sets recipients for mails send with :meth:`core.email.send_email_to_admins`.
If not set, all root users will be used."""

_mapping = {
"logRetention": "log_retention",
Expand Down
2 changes: 1 addition & 1 deletion src/viur/core/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def check_sib_quota() -> None:
logging.info(f"Already send an email for {limit = }.")
break

sendEMailToAdmins(
send_email_to_admins(
f"SendInBlue email budget {credits} ({idx}. warning)",
f"The SendInBlue email budget reached {credits} credits "
f"for {data['email']}. Please increase soon.",
Expand Down
2 changes: 1 addition & 1 deletion src/viur/core/modules/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@ def createNewUserIfNotExists():
msg = f"ViUR created a new admin-user for you!\nUsername: {uname}\nPassword: {pw}"

logging.warning(msg)
email.sendEMailToAdmins("New ViUR password", msg)
email.send_email_to_admins("New ViUR password", msg)


# DEPRECATED ATTRIBUTES HANDLING
Expand Down
2 changes: 2 additions & 0 deletions src/viur/core/scripts/viur_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
"toDB": "write",
"fromDB": "read",
re.compile(r"\bsubSkel\b"): "subskel",
"sendEMailToAdmins": "send_email_to_admins",
"sendEMail": "send_email",

# WARNING: THESE MUST BE KEPT AT THE END, THE ORDER MATTERS!!!!
"projectID": "conf.instance.project_id",
Expand Down
2 changes: 1 addition & 1 deletion src/viur/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def deferred(self, *args, **kwargs):
retryCount = req.headers.get("X-Appengine-Taskretrycount", None)
if retryCount and int(retryCount) == self.retryCountWarningThreshold:
from viur.core import email
email.sendEMailToAdmins(
email.send_email_to_admins(
"Deferred task retry counter exceeded warning threshold",
f"""Task {req.headers.get("X-Appengine-Taskname", "")} is retried for the {retryCount}th time."""
)
Expand Down