Merge branch 'develop' into mariadb-client-refactor
This commit is contained in:
commit
3ddac3ba58
7 changed files with 55 additions and 44 deletions
|
|
@ -79,7 +79,7 @@ class _dict(dict):
|
|||
return _dict(self)
|
||||
|
||||
|
||||
def _(msg, lang=None, context=None):
|
||||
def _(msg, lang=None, context=None) -> str:
|
||||
"""Returns translated string in current lang, if exists.
|
||||
Usage:
|
||||
_('Change')
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
"otp_issuer_name",
|
||||
"email",
|
||||
"email_footer_address",
|
||||
"email_retry_limit",
|
||||
"column_break_18",
|
||||
"disable_standard_email_footer",
|
||||
"hide_footer_in_auto_email_reports",
|
||||
|
|
@ -495,8 +496,8 @@
|
|||
"fieldname": "allow_older_web_view_links",
|
||||
"fieldtype": "Check",
|
||||
"label": "Allow Older Web View Links (Insecure)"
|
||||
},
|
||||
{
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_64",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
|
|
@ -518,12 +519,18 @@
|
|||
"fieldtype": "Duration",
|
||||
"label": "Reset Password Link Expiry Duration",
|
||||
"non_negative": 1
|
||||
},
|
||||
{
|
||||
"default": "3",
|
||||
"fieldname": "email_retry_limit",
|
||||
"fieldtype": "Int",
|
||||
"label": "Email Retry Limit"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-cog",
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2022-05-19 00:00:18.095269",
|
||||
"modified": "2022-06-21 13:55:04.796152",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "System Settings",
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ from frappe.utils import (
|
|||
split_emails,
|
||||
)
|
||||
|
||||
MAX_RETRY_COUNT = 3
|
||||
|
||||
|
||||
class EmailQueue(Document):
|
||||
DOCTYPE = "Email Queue"
|
||||
|
|
@ -183,7 +181,7 @@ def send_mail(email_queue_name, is_background_task=False):
|
|||
|
||||
class SendMailContext:
|
||||
def __init__(self, queue_doc: Document, is_background_task: bool = False):
|
||||
self.queue_doc = queue_doc
|
||||
self.queue_doc: EmailQueue = queue_doc
|
||||
self.is_background_task = is_background_task
|
||||
self.email_account_doc = queue_doc.get_email_account()
|
||||
self.smtp_server = self.email_account_doc.get_smtp_server()
|
||||
|
|
@ -210,7 +208,7 @@ class SendMailContext:
|
|||
email_status = (self.sent_to and "Partially Sent") or "Not Sent"
|
||||
self.queue_doc.update_status(status=email_status, commit=True)
|
||||
elif exc_type:
|
||||
if self.queue_doc.retry < MAX_RETRY_COUNT:
|
||||
if self.queue_doc.retry < get_email_retry_limit():
|
||||
update_fields = {"status": "Not Sent", "retry": self.queue_doc.retry + 1}
|
||||
else:
|
||||
update_fields = {"status": (self.sent_to and "Partially Errored") or "Error"}
|
||||
|
|
@ -287,16 +285,16 @@ class SendMailContext:
|
|||
).decode()
|
||||
return message
|
||||
|
||||
def get_unsubscribe_str(self, recipient_email):
|
||||
def get_unsubscribe_str(self, recipient_email: str) -> str:
|
||||
unsubscribe_url = ""
|
||||
|
||||
if self.queue_doc.add_unsubscribe_link and self.queue_doc.reference_doctype:
|
||||
doctype, doc_name = self.queue_doc.reference_doctype, self.queue_doc.reference_name
|
||||
unsubscribe_url = get_unsubcribed_url(
|
||||
doctype,
|
||||
doc_name,
|
||||
recipient_email,
|
||||
self.queue_doc.unsubscribe_method,
|
||||
self.queue_doc.unsubscribe_param,
|
||||
reference_doctype=self.queue_doc.reference_doctype,
|
||||
reference_name=self.queue_doc.reference_name,
|
||||
email=recipient_email,
|
||||
unsubscribe_method=self.queue_doc.unsubscribe_method,
|
||||
unsubscribe_params=self.queue_doc.unsubscribe_param,
|
||||
)
|
||||
|
||||
return quopri.encodestring(unsubscribe_url.encode()).decode()
|
||||
|
|
@ -372,6 +370,10 @@ def on_doctype_update():
|
|||
)
|
||||
|
||||
|
||||
def get_email_retry_limit():
|
||||
return cint(frappe.db.get_system_setting("email_retry_limit")) or 3
|
||||
|
||||
|
||||
class QueueBuilder:
|
||||
"""Builds Email Queue from the given data"""
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import re
|
|||
from email import policy
|
||||
from email.header import Header
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from typing import Optional
|
||||
|
||||
import frappe
|
||||
from frappe.email.doctype.email_account.email_account import EmailAccount
|
||||
|
|
@ -353,7 +354,7 @@ def get_formatted_html(
|
|||
print_html=None,
|
||||
email_account=None,
|
||||
header=None,
|
||||
unsubscribe_link=None,
|
||||
unsubscribe_link: Optional[frappe._dict] = None,
|
||||
sender=None,
|
||||
with_container=False,
|
||||
):
|
||||
|
|
|
|||
|
|
@ -67,37 +67,24 @@ def get_emails_sent_today(email_account=None):
|
|||
return frappe.db.sql(q, q_args)[0][0]
|
||||
|
||||
|
||||
def get_unsubscribe_message(unsubscribe_message, expose_recipients):
|
||||
if unsubscribe_message:
|
||||
unsubscribe_html = """<a href="<!--unsubscribe_url-->"
|
||||
target="_blank">{0}</a>""".format(
|
||||
unsubscribe_message
|
||||
)
|
||||
else:
|
||||
unsubscribe_link = """<a href="<!--unsubscribe_url-->"
|
||||
target="_blank">{0}</a>""".format(
|
||||
_("Unsubscribe")
|
||||
)
|
||||
unsubscribe_html = _("{0} to stop receiving emails of this type").format(unsubscribe_link)
|
||||
|
||||
html = """<div class="email-unsubscribe">
|
||||
def get_unsubscribe_message(
|
||||
unsubscribe_message: str, expose_recipients: str
|
||||
) -> frappe._dict[str, str]:
|
||||
unsubscribe_message = unsubscribe_message or _("Unsubscribe")
|
||||
unsubscribe_link = f'<a href="<!--unsubscribe_url-->" target="_blank">{unsubscribe_message}</a>'
|
||||
unsubscribe_html = _("{0} to stop receiving emails of this type").format(unsubscribe_link)
|
||||
html = f"""<div class="email-unsubscribe">
|
||||
<!--cc_message-->
|
||||
<div>
|
||||
{0}
|
||||
{unsubscribe_html}
|
||||
</div>
|
||||
</div>""".format(
|
||||
unsubscribe_html
|
||||
)
|
||||
</div>"""
|
||||
|
||||
text = f"\n\n{unsubscribe_message}: <!--unsubscribe_url-->\n"
|
||||
if expose_recipients == "footer":
|
||||
text = "\n<!--cc_message-->"
|
||||
else:
|
||||
text = ""
|
||||
text += "\n\n{unsubscribe_message}: <!--unsubscribe_url-->\n".format(
|
||||
unsubscribe_message=unsubscribe_message
|
||||
)
|
||||
text = f"\n<!--cc_message-->{text}"
|
||||
|
||||
return frappe._dict({"html": html, "text": text})
|
||||
return frappe._dict(html=html, text=text)
|
||||
|
||||
|
||||
def get_unsubcribed_url(
|
||||
|
|
|
|||
|
|
@ -613,8 +613,8 @@
|
|||
<symbol viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" id="icon-expenses">
|
||||
<path d="M17 16a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V2.37a.2.2 0 0 1 .31-.168l1.75 1.143a.5.5 0 0 0 .547 0L7.393 2.18a.5.5 0 0 1 .547 0l1.787 1.166a.5.5 0 0 0 .546 0L12.06 2.18a.5.5 0 0 1 .547 0l1.786 1.166a.5.5 0 0 0 .547 0l1.75-1.143a.2.2 0 0 1 .31.167V16z"
|
||||
stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="square"></path>
|
||||
<path d="M12.925 9.097l-.298 1.052h-.904c-.174 1.15-.997 1.986-2.748 2.093l2.787 3.413v.072h-1.556l-3.05-3.703-.01-.83H8.66c.938 0 1.53-.372 1.705-1.045H7.04l.298-1.052h2.992c-.196-.601-.737-.963-1.67-.963H7.04L7.351 7h5.578l-.302 1.061-1.343-.008c.222.298.367.652.43 1.044h1.211z"
|
||||
fill="#192734" stroke="none"></path>
|
||||
<path d="m13.13,8.1l-0.3,1.05l-0.91,0c-0.17,1.15 -0.99,1.98 -2.74,2.09l2.78,3.41l0,0.08l-1.55,0l-3.05,-3.71l-0.01,-0.83l1.51,0c0.94,0 1.53,-0.37 1.71,-1.04l-3.33,0l0.3,-1.05l2.99,0c-0.2,-0.6 -0.74,-0.97 -1.67,-0.97l-1.62,0l0.31,-1.13l5.58,0l-0.3,1.06l-1.35,-0.01c0.23,0.3 0.37,0.66 0.43,1.05l1.22,0z"
|
||||
fill="var(--icon-stroke)" stroke="none"></path>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" id="icon-income">
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 107 KiB |
|
|
@ -1993,7 +1993,7 @@ QR Code,QR-Code,
|
|||
QR Code for Login Verification,QR Code für Login-Bestätigung,
|
||||
QZ Tray Connection Active!,QZ-Tray-Verbindung aktiv!,
|
||||
QZ Tray Failed: ,QZ-Fach fehlgeschlagen:,
|
||||
Quarter Day,Quartalstag,
|
||||
Quarter Day,Viertel-Tag,
|
||||
Query,Abfrage,
|
||||
Query Report,Abfragebericht,
|
||||
Query must be a SELECT,Abfrage muss ein SELECT sein,
|
||||
|
|
@ -4793,3 +4793,17 @@ Reset to default,Auf Standard zurücksetzen,
|
|||
Column Width,Spaltenbreite,
|
||||
Choose Kanban Board,Kanban-Tafel auswählen,
|
||||
Create New Board,Neue Tafel erstellen,
|
||||
Only If Creator,Nur wenn Ersteller,
|
||||
Rebuild Tree,Baum neu aufbauen,
|
||||
Customize Dashboard,Dashboard anpassen,
|
||||
Reset Dashboard Customizations,Dashboard-Anpassungen zurücksetzen,
|
||||
Add {0},{0} hinzufügen,
|
||||
descending,absteigend,
|
||||
ascending,aufsteigend,
|
||||
Next Document,Nächstes Dokument,
|
||||
Previous Document,Vorheriges Dokument,
|
||||
Mark all as read,Alle als gelesen markieren,
|
||||
See all Activity,Alle Aktivitäten anzeigen,
|
||||
Go to Notification Settings List,Gehe zur Listenansicht Benachrichtigungseinstellungen,
|
||||
Load more,Mehr laden,
|
||||
Edit Full Form,Vollständiges Formular bearbeiten,
|
||||
|
|
|
|||
|
Loading…
Add table
Reference in a new issue