Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support non-PNG embedded images as dict #16

Merged
merged 3 commits into from
Jan 19, 2022
Merged

Conversation

Miksus
Copy link
Owner

@Miksus Miksus commented Jan 18, 2022

Fix to support also other than just PNG formats passed as dict, like:

email.send(
    subject="Example",
    receivers=[...],
    html="<h1>Example</h1> {{ my_image }}",
    body_images={
        'my_image': {
            'content': b'<image as bytes>',
            'maintype': 'image',
            'subtype': 'jpeg',
        }
    }
)

@Miksus
Copy link
Owner Author

Miksus commented Jan 18, 2022

Probably good to have one JPEG test as well before merging.

@Miksus Miksus added the bug Something isn't working label Jan 18, 2022
@Miksus Miksus linked an issue Jan 18, 2022 that may be closed by this pull request
It's redundant to specify maintype as it should be image when we embed
such to the body. Also slightly reworded the exception message to
prevent printing image data.
@codecov-commenter
Copy link

Codecov Report

Merging #16 (422af9d) into master (f19d4ca) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #16      +/-   ##
==========================================
- Coverage   99.59%   99.59%   -0.01%     
==========================================
  Files          12       12              
  Lines         494      492       -2     
==========================================
- Hits          492      490       -2     
  Misses          2        2              
Impacted Files Coverage Δ
redmail/email/body.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f19d4ca...422af9d. Read the comment docs.

@Miksus
Copy link
Owner Author

Miksus commented Jan 19, 2022

Also, now one does not need to specify maintype as that probably should always be "image".

@Miksus Miksus merged commit 91fe422 into master Jan 19, 2022
@Miksus Miksus deleted the fix/image_as_dict branch November 15, 2022 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Base64 img
2 participants