1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-12 21:10:00 +00:00

Merge branch 'janeczku-master'

# Conflicts:
#	cps/helper.py
#	cps/tasks/convert.py
#	cps/templates/user_edit.html
This commit is contained in:
gjutras 2022-07-08 16:42:14 -04:00
commit 0a7345186d
3 changed files with 30 additions and 23 deletions

View File

@ -110,9 +110,11 @@ def convert_book_format(book_id, calibre_path, old_book_format, new_book_format,
# Texts are not lazy translated as they are supposed to get send out as is # Texts are not lazy translated as they are supposed to get send out as is
def send_test_mail(ereader_mail, user_name): def send_test_mail(ereader_mail, user_name):
WorkerThread.add(user_name, TaskEmail(_(u'Calibre-Web test e-mail'), None, None, for email in ereader_mail.split(','):
config.get_mail_settings(), ereader_mail, N_(u"Test e-mail"), email = email.strip()
_(u'This e-mail has been sent via Calibre-Web.'))) WorkerThread.add(user_name, TaskEmail(_(u'Calibre-Web test e-mail'), None, None,
config.get_mail_settings(), email, N_(u"Test e-mail"),
_(u'This e-mail has been sent via Calibre-Web.')))
return return
@ -222,9 +224,11 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id)
converted_file_name = entry.name + '.' + book_format.lower() converted_file_name = entry.name + '.' + book_format.lower()
link = '<a href="{}">{}</a>'.format(url_for('web.show_book', book_id=book_id), escape(book.title)) link = '<a href="{}">{}</a>'.format(url_for('web.show_book', book_id=book_id), escape(book.title))
email_text = N_(u"%(book)s send to E-Reader", book=link) email_text = N_(u"%(book)s send to E-Reader", book=link)
WorkerThread.add(user_id, TaskEmail(_(u"Send to E-Reader"), book.path, converted_file_name, for email in ereader_mail.split(','):
config.get_mail_settings(), ereader_mail, email = email.strip()
email_text, _(u'This e-mail has been sent via Calibre-Web.'))) WorkerThread.add(user_id, TaskEmail(_(u"Send to E-Reader"), book.path, converted_file_name,
config.get_mail_settings(), email,
email_text, _(u'This e-mail has been sent via Calibre-Web.')))
return return
return _(u"The requested file could not be read. Maybe wrong permissions?") return _(u"The requested file could not be read. Maybe wrong permissions?")
@ -652,14 +656,15 @@ def check_username(username):
return username return username
def valid_email(email): def valid_email(emails):
email = email.strip() for email in emails.split(','):
# Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation email = email.strip()
if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$", # Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation
email): if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$",
log.error(u"Invalid e-mail address format") email):
raise Exception(_(u"Invalid e-mail address format")) log.error(u"Invalid e-mail address format")
return email raise Exception(_(u"Invalid e-mail address format"))
return emails
# ################################# External interface ################################# # ################################# External interface #################################

View File

@ -90,14 +90,16 @@ class TaskConvert(CalibreTask):
# todo: figure out how to incorporate this into the progress # todo: figure out how to incorporate this into the progress
try: try:
EmailText = N_(u"%(book)s send to E-Reader", book=escape(self.title)) EmailText = N_(u"%(book)s send to E-Reader", book=escape(self.title))
worker_thread.add(self.user, TaskEmail(self.settings['subject'], for email in self.ereader_mail.split(','):
self.results["path"], email = email.strip()
filename, worker_thread.add(self.user, TaskEmail(self.settings['subject'],
self.settings, self.results["path"],
self.ereader_mail, filename,
EmailText, self.settings,
self.settings['body'], email,
internal=True) EmailText,
self.settings['body'],
internal=True)
) )
except Exception as ex: except Exception as ex:
return self._handleError(str(ex)) return self._handleError(str(ex))

View File

@ -25,7 +25,7 @@
</div> </div>
{% endif %} {% endif %}
<div class="form-group"> <div class="form-group">
<label for="kindle_mail">{{_('Send to E-Reader E-mail Address')}}</label> <label for="kindle_mail">{{_('Send to E-Reader E-mail Address. Use comma to seperate emails for multiple E-Readers.')}}</label>
<input type="email" class="form-control" name="kindle_mail" id="kindle_mail" value="{{ content.kindle_mail if content.kindle_mail != None }}"> <input type="email" class="form-control" name="kindle_mail" id="kindle_mail" value="{{ content.kindle_mail if content.kindle_mail != None }}">
</div> </div>
{% if not content.role_anonymous() %} {% if not content.role_anonymous() %}