gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
https://gotify.net
Other
11.13k stars 620 forks source link

Assistance with json format for multiple message extras #641

Closed Circenn5130 closed 6 months ago

Circenn5130 commented 6 months ago

Have you read the documentation?

You are setting up gotify in

Describe your problem

I could use some help with formatting of the "Extras" section when there's more than one. I haven't been able to get an image on android from the notifications (when you swipe down) It just appears as "obj". They're only visible upon opening the app and in the web browser. I'm not sure if my formatting is just wrong, or if it's something outside of that so I'm hoping for clarification. Thank you!

{
  "title": "Title",
  "message": "![Info](https://myurl)",
  "priority": "5",
  "extras": {
    "client::display": {
      "contentType": "text/markdown"
    },
    "client::notification": {
      "bigImageUrl": "https://myurl"
    }
  }
}
jmattheis commented 6 months ago

What kind of image is it? Is it accessible in a browser? The example you provided has invalid syntax and the priority must be an integer. E.g. this example works for me:

{
  "title": "Title",
  "message": "![Info](https://placebear.com/400/300)",
  "priority": 5,
  "extras": {
    "client::display": {
      "contentType": "text/markdown"
    },
    "client::notification": {
      "bigImageUrl": "https://placebear.com/400/300"
    }
  }
}
Circenn5130 commented 6 months ago

Per our discussion on Element:

Hi, this is a setup for Blueiris. The images in the "message" and "bigimageurl" are accessible from a web browser. the image format is .jpg

Confirming that the provided layout was exactly what I needed and resolved my issue. Thank you so much for your help!

Circenn5130 commented 6 months ago

Here's the final version of the script in case anyone else wants to do similar. It was definitely a pain since Blueiris has it own set of variables which made it so I couldn't just script in powershell and be done. Otherwise BIs variables wouldn't work.

  1. I had to create an alert action set to write to file -- powershell extension (.ps1) - (overwrite) with the code below pasted in.
  2. Another action set to send the photo to the web server I use to so that it's accessible without requiring logging in to blueiris,
  3. And a final alert action set to run the .ps1 powershell file from step 1 using powershell 7

A kind of messy solution I'm sure, but I'm over it after struggling with it for the last couple days lol

$TITLE="&CAM &MEMO"
$MESSAGE="![Blueiris](https://url/&ALERT_PATH)"
$IMG="https://url/&ALERT_PATH"
$URL="https://url/message?token=<token>"
$Priority="5"

$json = '{
    "title": "'+$Title+'",
    "message": "'+$MESSAGE+'",
    "priority": '+$Priority+',
    "extras": {
        "client::display": {
        "contentType": "text/markdown"
        },
        "client::notification": {
        "bigImageUrl": "'+$IMG+'"
        }
    }
}'

curl.exe $URL --header 'Content-Type: application/json' --data-raw $json