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

Ntfy inline images displayed #892

Merged
merged 3 commits into from Jul 1, 2023
Merged

Conversation

caronc
Copy link
Owner

@caronc caronc commented Jun 24, 2023

Description:

Related issue (if applicable): #888

Inline images are not displayed.

# This works:
curl -T test/var/apprise-test.jpeg \
   localhost:8080/test?filename=apprise-test.jpeg -vvv

Server Response

  • mime-type get's set to image/jpeg as expected
    {"id":"jhMKlWLVdsno","time":1687709611,"expires":1687752811,"event":"message","topic":"test","message":"You received a file: apprise-test.jpeg","attachment":{"name":"apprise-test.jpeg","type":"image/jpeg","size":73667,"expires":1687720411,"url":"http://localhost:8080/file/jhMKlWLVdsno.jpg"}}
  • Screenshot from 2023-06-25 12-39-27
# This doesn't work:
bin/apprise -vv ntfy://localhost:8080/test -b test \
  --attach test/var/apprise-test.jpeg

Server Response

  • mime-type get's set to application/octet-stream for some reason
    {"id": "tAv3ijYRHTeX", "time": 1687709905, "expires": 1687753105, "event": "message", "topic": "test", "message": "test", "icon": "https://github.com/caronc/apprise/raw/master/apprise/assets/themes/default/apprise-info-256x256.png", "attachment": {"name": "apprise-test.jpeg", "type": "application/octet-stream", "size": 73846, "expires": 1687720705, "url": "http://localhost:8080/file/tAv3ijYRHTeX.bin"}}
  • Screenshot from 2023-06-25 12-39-05

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@888-ntfy-image-inline-display

# Create a ntfy configuration to test against (set with attachment support)
cat << _EOF > ~/ntfy.server.yml
base-url: "http://localhost:8080"
attachment-cache-dir: "/var/cache/ntfy/attachments"
_EOF

# Start ntfy with Attachment support
docker run -p 8080:80 -v ~/ntfy.server.yml:/etc/ntfy/server.yml:ro -it binwiederhier/ntfy:v2.5.0 serve

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message"  "ntfy://localhost:8080/test"

@caronc caronc force-pushed the 888-ntfy-image-inline-display branch from 7d55fe0 to 645ae9e Compare June 25, 2023 16:20
@codecov-commenter
Copy link

codecov-commenter commented Jun 25, 2023

Codecov Report

Patch coverage: 81.81% and project coverage change: -0.02 ⚠️

Comparison is base (ab55aef) 100.00% compared to head (66ed0eb) 99.98%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@             Coverage Diff             @@
##            master     #892      +/-   ##
===========================================
- Coverage   100.00%   99.98%   -0.02%     
===========================================
  Files          118      118              
  Lines        15692    15693       +1     
  Branches      3211     3207       -4     
===========================================
- Hits         15692    15691       -1     
- Misses           0        1       +1     
- Partials         0        1       +1     
Impacted Files Coverage Δ
apprise/plugins/NotifyNtfy.py 99.25% <81.81%> (-0.75%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@caronc
Copy link
Owner Author

caronc commented Jun 25, 2023

@amotl, i spent a few hours on this one and i'm still stuck.

I can't seem to figure out why the requests library posts it's attachments with application/octet-stream vs curl which sends the correct mimetype.

I'm thinking it's the syntax in the way i handle the files directive on the post call, but i can't see anything out of the ordinary. I would love a second pair of eyes on this to see if you can spot anything obvious?

@caronc caronc changed the title moved filename reference to Header (out of GET params) Ntfy inline images displayed Jun 25, 2023
@amotl
Copy link
Collaborator

amotl commented Jun 25, 2023

Dear Chris,

I've responded to your question at #888 (comment).

With kind regards,
Andreas.

@caronc caronc merged commit 276da2e into master Jul 1, 2023
14 checks passed
@caronc caronc deleted the 888-ntfy-image-inline-display branch July 1, 2023 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants