MexHigh / Gotify-Webhooks-Plugin

Plugin for Gotify to display generic webhook requests
https://git.leon.wtf/leon/gotify-webhooks-plugin
MIT License
8 stars 2 forks source link

Feature: Markdown #1

Closed bun-dev closed 3 months ago

bun-dev commented 4 months ago

Is there any chance of this supporting markdown instead of raw json strings to gotify? thanks Screenshot_20240625-072312_Gotify

MexHigh commented 4 months ago

Could you elaborate how you like the payload to be displayed and can you give examples? Your service (Grafana?) seems to posts JSON to the webhook.

s1oz commented 3 months ago

您能否详细说明您希望如何显示有效负载并举例说明?您的服务(Grafana?)似乎将 JSON 发布到 webhook。

Could you elaborate how you like the payload to be displayed and can you give examples? Your service (Grafana?) seems to posts JSON to the webhook.

QQ截图20240806155552 Do you support Markdown syntax? The following command doesn't display correctly after I use it:

"Hello: ![](https://gotify.net/img/logo.png)"
MexHigh commented 3 months ago

No there is currently no support for it, since I don't know which service uses markdown as webhook payload. Is there any particular reason why you try to POST markdown to Gotify via webhooks instead of just using the API?

The following call should work for displaying Markdown:

curl -X POST "https://<host>/message?token=<token>" -H "Content-Type: application/json" \
  -d "{ \"title\": \"Hello World\", \"message\": \"# Markdown\n\n- list\n\n- list2\", \"extras\": { \"client::display\": { \"contentType\": \"text/markdown\" } } }"

image

s1oz commented 3 months ago

No there is currently no support for it, since I don't know which service uses markdown as webhook payload. Is there any particular reason why you try to POST markdown to Gotify via webhooks instead of just using the API?

The following call should work for displaying Markdown:

curl -X POST "https://<host>/message?token=<token>" -H "Content-Type: application/json" \
  -d "{ \"title\": \"Hello World\", \"message\": \"# Markdown\n\n- list\n\n- list2\", \"extras\": { \"client::display\": { \"contentType\": \"text/markdown\" } } }"

image

Due to the delayed notifications from Synology's official Ds cam app, I found in the official documentation that webhook support is available. I would like to use Gotify to push notifications and images. Could you please consider adding support for this feature?

Thank you!

MexHigh commented 3 months ago

Can you set the content type in the Surveillance Station? I could add a condition for text/markdown and try to use Gotifys Markdown display option for the payload.

Will try that out next week.

s1oz commented 3 months ago

Can you set the content type in the Surveillance Station? I could add a condition for text/markdown and try to use Gotifys Markdown display option for the payload.

Will try that out next week.

It cannot be set directly to text/markdown; only the following options are available:

POST
PUT
application/x-www-form-urlencoded
application/json
text/plain
MexHigh commented 3 months ago

Can you set additional request headers? Otherwise, this will be ugly to implement I think.

MexHigh commented 3 months ago

Done! Markdown is now supported. You can set the content type via a query parameter (e.g. https://.../webhook?content-type=text/markdown). You can also take a look at the README for other options.

You can grab the plugin here: https://git.leon.wtf/leon/gotify-webhooks-plugin/-/packages/15

Please let me know if this works for you!