mbround18 / valheim-docker

Valheim Docker powered by Odin. The Valheim dedicated gameserver manager which is designed with resiliency in mind by providing automatic updates, world backup support, and a user friendly cli interface.
https://hub.docker.com/r/mbround18/valheim
BSD 3-Clause "New" or "Revised" License
767 stars 82 forks source link

Odin notify fails with discord webhook #226

Closed arevak closed 3 years ago

arevak commented 3 years ago

Odin notify is generating messages like this:

{"event_type":{"name":"Broadcast","status":"Triggered"},"event_message":"test","timestamp":"2021-02-28T19:43:20.746633600-08:00"}

and responds with

[ODIN][ERROR] - Request failed! 400 Bad Request, {"message": "Cannot send an empty message", "code": 50006}

I think it needs to be content instead of event_message

Not too familiar with rust or I'd submit a PR and I don't know where the odin source is

mbround18 commented 3 years ago

Odin source is in this repo under sec, that event message gets put into content. Are you on the latest dev image for discord notifications? 0.o that's the same image I am using now to run the release notifications.

Try putting quotes around your broadcast message

arevak commented 3 years ago

I did a docker pull like a day or two ago., How do I know whether im on the latest dev image? Is the image id useful?

arevak commented 3 years ago

So to test I did the following:

docker-compose exec --user steam valheim bash
DEBUG_MODE=1 odin notify -r test

docker-compose.yml

version: "3"
services:
  valheim:
    image: mbround18/valheim:latest
    ports:
      - 2456:2456/udp
      - 2457:2457/udp
      - 2458:2458/udp
    environment:
      - PORT=2456
      - NAME="*****"
      - WORLD="Dedicated"
      - PASSWORD="*******"
      - TZ=America/Los_Angeles
      - PUBLIC=0
      - AUTO_UPDATE=1
      - AUTO_UPDATE_SCHEDULE="0 4 * * *"
      - WEBHOOK_URL="https://discordapp.com/api/webhooks/*****/******"
      - UPDATE_ON_STARTUP=1
    volumes:
    - ./valheim/saves:/home/steam/.config/unity3d/IronGate/Valheim
    - ./valheim/server:/home/steam/valheim
steam@c6411a638b4e:~/valheim$ DEBUG_MODE=1 odin notify -r test
[ODIN][DEBUG] - Debugging set to true
[ODIN][DEBUG] - Debug mode enabled!
[ODIN][DEBUG] - Launching notify command...
[ODIN][DEBUG] - Checking env for MESSAGE
[ODIN][DEBUG] - Checking env for webhook_url
[ODIN][DEBUG] - Env variable found webhook_url="https://discordapp.com/api/webhooks/****/*****"
[ODIN][INFO]  - Sending Broadcast: test
[ODIN][DEBUG] - Webhook enabled, sending notification Broadcast
[ODIN][DEBUG] - Webhook URL: "https://discordapp.com/api/webhooks/****/****"
[ODIN][DEBUG] - Webhook Payload: {"event_type":{"name":"Broadcast","status":"Triggered"},"event_message":"test","timestamp":"2021-02-28T21:25:55.470995900-08:00"}
[ODIN][ERROR] - [Broadcast]: Error with webhook! Status 500

Filtered out sensitive crap with ***

arevak commented 3 years ago

Sorry also taking the same webhook API, throwing it into postman and posting the same payload gets the same response. Editing the payload to have content instead of event_message works just fine.

Are there maybe multiple ways to enable the webhook? Some extra step I'm missing maybe? I googled around a bit and wasnt able to find the api docs that reference this type of usage of the webhook.

mbround18 commented 3 years ago

It should not be using the payload you see there, good find! Ill take a look at it

CosmicHorrorDev commented 3 years ago

There was a recent change to support the discordapp base too. I think it's just an outdated image

arevak commented 3 years ago

Totally right, updated the image and it worked like a charm! Bang up job guys