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

Render markdown / HTML in OS-level notifications #1982

Closed
pranavmishra90 opened this issue Nov 8, 2024 · 1 comment
Closed

Render markdown / HTML in OS-level notifications #1982

pranavmishra90 opened this issue Nov 8, 2024 · 1 comment
Labels
A-Electron A-Notifications O-Occasional Affects or can be seen by some users regularly or most users rarely T-Enhancement Z-Upstream

Comments

@pranavmishra90
Copy link

Your use case

What would you like to do?

Notifications from webhooks (via Hookshot) are not 'rendered' in the preview. Rather, Element provides a notification that a JSON payload was received.

It would be wonderful to have the notification display rendered message, rather than a notification on the incoming webhook itself

Why would you like to do it?

In the screenshot below, you can see how the incoming message looks like vs. the notification bubble.

image

(Minimum working example code provided below)

How would you like to achieve it?

Not sure on the specifics of how these notifications are rendered in Electron

Have you considered any alternatives?

Potentially could have the message fall back to plain text if we cannot render markdown and/or HTML.

Additional context

A minimum working code example (MWE) used to render the above notification:

#!/bin/bash

# Hardcoding for the MWE
# source ~/.shell_secrets
MATRIX_SERVER_WEBHOOK="https://example.com/some_webhook_token_here"

# Check if MATRIX_SERVER_WEBHOOK is set
if [ -z "$MATRIX_SERVER_WEBHOOK" ]; then
  echo "MATRIX_SERVER_WEBHOOK is not set. Exiting."
  exit 1
fi

# Get the system hostname
hostname=$(hostname -s)

# Get the current date and time
current_time=$(date "+%m-%d-%Y at %I:%M %p")

# Define the JSON payload
json_payload='{
    "version": "v2",
    "html": "<h3>'Server": $hostname"'</h3>Startup complete<br>Time: '"$current_time"'"
}'

# Send the JSON payload via curl to the webhook URL
response=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$MATRIX_SERVER_WEBHOOK" \
    -H "Content-Type: application/json" \
    -d "$json_payload")

# Check the response code to determine if the request was successful
if [[ "$response" -eq 200 || "$response" -eq 202 ]]; then
    echo "Notification sent successfully"
else
    echo "Failed to send notification. Status code: $response"
fi
@dosubot dosubot bot added A-Notifications O-Occasional Affects or can be seen by some users regularly or most users rarely labels Nov 8, 2024
@t3chguy
Copy link
Member

t3chguy commented Nov 8, 2024

This is unsupported by Electron outside of certain Linux environments, and even then we can't detect when it is supported or when HTML would just be rendered as a string. I suggest raising a feature request with Electron/Chromium.

@t3chguy t3chguy closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Electron A-Notifications O-Occasional Affects or can be seen by some users regularly or most users rarely T-Enhancement Z-Upstream
Projects
None yet
Development

No branches or pull requests

2 participants