Resolved empty attachment handling when feature disabled

This commit is contained in:
Chris Caron 2025-02-18 15:23:34 -05:00
parent 4c038de8b3
commit bb23e50ffe

View File

@ -257,6 +257,14 @@ def parse_attachments(attachment_payload, files_request):
"""
attachments = []
if settings.APPRISE_ATTACH_SIZE <= 0:
if not (attachment_payload and files_request):
# No further processing required
return []
# Otherwise we need to raise an error
raise ValueError("Attachment support has been disabled")
# Attachment Count
count = sum([
0 if not isinstance(attachment_payload, (set, tuple, list))
@ -269,9 +277,6 @@ def parse_attachments(attachment_payload, files_request):
attachment_payload = (attachment_payload, )
count += 1
if settings.APPRISE_ATTACH_SIZE <= 0:
raise ValueError("Attachment support has been disabled")
if settings.APPRISE_MAX_ATTACHMENTS > 0 and count > settings.APPRISE_MAX_ATTACHMENTS:
raise ValueError(
"There is a maximum of %d attachments" %