Skip to content

Commit

Permalink
fix: E-Mail methods has been renamed
Browse files Browse the repository at this point in the history
* Add name mapping in viur-migrate
* Rename calls in core itself
  • Loading branch information
sveneberth committed Jan 29, 2025
1 parent 3c8680f commit cbee423
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
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_emailToAdmins(
"Debug mode enabled",
"ViUR just started a new Instance with call tracing enabled! This might log sensitive information!"
)
Expand Down
5 changes: 3 additions & 2 deletions src/viur/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:`email.send_emailToAdmins`.
If not set, all root users will be used."""

_mapping = {
"logRetention": "log_retention",
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_emailToAdmins("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",
"sendEMail": "send_email",
"sendEMailToAdmins": "send_email_to_admins",

# 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_emailToAdmins(
"Deferred task retry counter exceeded warning threshold",
f"""Task {req.headers.get("X-Appengine-Taskname", "")} is retried for the {retryCount}th time."""
)
Expand Down

0 comments on commit cbee423

Please sign in to comment.