Skip to content

Commit

Permalink
Replace the content-type on ics files (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn authored Nov 27, 2024
1 parent d8b866f commit 5d7a0bf
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions backend/src/appointment/controller/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,24 @@ def build(self):

# add attachment(s) as multimedia parts
for a in self._attachments():
# Attach it to the html payload
message.get_payload()[1].add_related(
a.data,
a.mime_main,
a.mime_sub,
cid=f'<{a.filename}>',
filename=a.filename,
)
# Handle ics files differently than inline images
if a.mime_main == 'text' and a.mime_sub == 'calendar':
message.add_attachment(
a.data,
maintype=a.mime_main, subtype=a.mime_sub,
filename=a.filename
)
# Fix the header of the attachment
message.get_payload()[-1].replace_header('Content-Type', f'{a.mime_main}/{a.mime_sub}; charset="UTF-8"; method=REQUEST')
else:
# Attach it to the html payload
message.get_payload()[1].add_related(
a.data,
a.mime_main,
a.mime_sub,
cid=f'<{a.filename}>',
filename=a.filename,
)

return message

Expand Down

0 comments on commit 5d7a0bf

Please sign in to comment.