* fix: prevent emails from being queued multiple times
* style: fmt
* refactor: optimistic error handling
- Combined email queue sending to single call instead of different
branches for testing.
- If failing to get jobs -> attempt sending anyway. Failure could be
form one bad job which shouldn't completely stop everything.
* chore: type
Co-authored-by: Ankush Menat <ankush@frappe.io>
We have hardcoded "Log settings" to only apply on 3 doctypes, there are
few more logging doctypes in core which are not cleared right now, on
top of that it's not easy for user to configure all logging behaviour
from one place.
This change adds a table on log settings where logging doctypes that
support the interface required by log settings can auto-register and
show up in settings.
Currently only supported configuration is "number of days" to keep.
Currently this background job constantly fails because of the way query
is written:
1. It tries to find all docs to delete using select query
2. Deletes them by using `in query` with a HUGE amount of docs
3. Deletes child table with parent, again using `IN` query with huge
amount of docs.
This times out and never finishes on old sites.
Solution:
1. Modified deletion to straightaway delete all main table rows that are
older
2. Apply same deletion logic to child table rows.
PS: This has potential to leave some orphan child table rows behind for few more days iff modified time was later than parent doc (this is quite rare). But it's safe since child table doesn't contain "links" anyway.
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
replaced queue.send function with Queue builder.
Queue builder builds a queue from sendmail request and sends the mail
if requested to send mail immediately.
* Remove six for PY2 compatability since our dependencies are not, PY2
is legacy.
* Removed usages of utils from future/past libraries since they are
deprecated. This includes 'from __future__ ...' and 'from past...'
statements.
* Removed compatibility imports for PY2, switched from six imports to
standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
Usecase: Suppose I have hundred's of emails in the Email Queue and the flush job executes. While the execution of the flush job is going another flush job starts and so on. Because of this a list of flush jobs gets lined up in the background jobs queue.
To avoid this it is better to enqueue the send_one function inside the flush job this will very efficiently improve the performance of the flush job.
fixes issue where smtplib fails to encode the mail as ascii
Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
response = frappe.api.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
data = execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 61, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1042, in call
return fn(*args, **newargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 801, in reset_password
user.reset_password(send_email=True)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 234, in reset_password
self.password_reset_mail(link)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 253, in password_reset_mail
"password_reset", {"link": link}, now=True)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 298, in send_login_mail
delayed=(not now) if now!=None else self.flags.delay_emails, retry=3)
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 476, in sendmail
inline_images=inline_images, header=header, print_letterhead=print_letterhead)
File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 162, in send
print_letterhead=print_letterhead)
File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 185, in add
send_one(email_queue.name, now=True)
File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 475, in send_one
raise e
File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 415, in send_one
smtpserver.sess.sendmail(email.sender, recipient.recipient, message)
File "/usr/lib64/python3.6/smtplib.py", line 855, in sendmail
msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 335-339: ordinal not in range(128)
Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
mail status wasn't being set when the check was run, so the output for
any() would always be false, and none of the mails would have status set
to sent in the backend. moving the check to a point after setting status
for each email should fix this issue
Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
* start of tests
* rfc compliant emails for frappe.
* fix for deepsource
* fix length of strings.
* fix bug that I'm not sure where it came from?
* codacy and deepsource issues trying to keep them happy
* take a punt in the dark
* fix: use SMTPUTF8 instead of SMTP and other minor fixes
Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>