caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
10.91k stars 384 forks source link

matrix: Set default notifiction format to HTML #1083

Closed agx closed 3 months ago

agx commented 3 months ago

This ensures the org.matrix.custom.html is added which is usually what we want as otherwise no formatting is applied.

Description:

Set default notifiction format to HTML

This ensures the org.matrix.custom.html element is added which is usually what we want as otherwise no formatting is applied.

I assume there's a reason for not doing so by default but looking around I couldn't spot any as other plugins set this too.

Checklist

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@<this.branch-name>

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  <apprise url related to ticket>
caronc commented 3 months ago

I'm not sure if this is the best solution. The problem is if i open up my terminal and i define a matrix end point. With today's design, i can just do:

# my.test.script.sh can have entries like:
#   echo '' > /dev/null
#   my.tool 2>&1 >file <input
# ...
# apprise will deliver everything as what you see is what you get
cat my.test.script.sh | apprise -g matrix

If Matrix default is html, i will need to check and see if the < and other characters fed cause any disturbance (get treated as broken HTML, etc). If it still looks presentable, then perhaps this is okay.

Today if you want HTML data, you just need to add ?format=html to the end of your matrix:// URL.

But i'd be curious on your thoughts/rational (because to your point, email defaults to html and things work fine). Other step would be to verify that if you default to html that someone who types ?format=text it still allows one to send content the old way too.

agx commented 3 months ago

Thinking about this some more I guess what was actually after is having the "raw" text in body and (if it contains markdown formatting) having a formatted_body with HTML (and having "format": "org.matrix.custom.html" set too in this case) . This would match what other clients (e.g. Element) do which works with ?format=markdown so all is good from my side. Thanks!