rr- / szurubooru

Image board engine, Danbooru-style.
GNU General Public License v3.0
693 stars 174 forks source link

Webhooks, forbidden? #639

Open KenwoodFox opened 6 months ago

KenwoodFox commented 6 months ago

This might be silly but, im trying to get szurubooru to call a discord webhook using the webhook section in config, i get this in the logs though:


...
server-1  | [2024-03-13 16:45:01] szurubooru.func.net Unable to call webhook https://discord.com/api/webhooks/<id>/<secret>: HTTP Error 403: Forbidden
...

am i just being silly?
hujle commented 6 months ago

I think this is rather Discord issue than szurubooru's. This means Discord is blocking your server's connection to their API. I have the same issue with my instance and I tried to contact Discord support about it over a week ago. Got no response from them so far (which is kinda expected tbh, Discord support is full of shit).

KenwoodFox commented 6 months ago

How can it tell my server apart from me? im sitting right next to it, :confused:

hujle commented 6 months ago

...or, perhaps Discord doesn't like what szurubooru sends to their webhooks and blocking connection. It could be anything at this point.

Theenoro commented 6 months ago

What are you exactly trying to do? Ok Webhook, but what Info do you need in particular? (like Uploads? new Users?) You could need something like a service thingie which modifies/translates it and then send it to your original discord webhook url.

szurubooru -> service thingie -> discord webhook

I mean would be possible. Wrote last year a thingie to use szurubooru in a booru android app. Works like a charm, just needed to know what szurubooru sends and what the client expect to understand the response. Would be same here I suppose.

hujle commented 6 months ago

There is a webhook setting in ./server/config.yaml, line 66, and the expected behavior after inclusion of a webhook URL was simply a message appearing in Discord server's channel where the webhook was created. But instead, Discord API responds with HTTP Error: 403 Forbidden message.

Simple as that.

Theenoro commented 6 months ago

Started to create thingie which accepts the booru webhooks and transforms them into ones which discord could understand. I mean I get from szurubooru

{
  "operation": "created",
  "type": "post",
  "id": 1,
  "user": {
    "name": "Test",
    "avatarUrl": "data/avatars/test.png"
  },
  "data": {
    "source": null,
    "safety": "unsafe",
    "checksum": "",
    "flags": [],
    "featured": false,
    "tags": [],
    "relations": [],
    "notes": []
  },
  "time": "2024-03-13T23:35:57.964435Z"
}

and discord wants something like

{
  "content": "Hello, World!",
  "embeds": [
    {
      "title": "Hello, Embed!",
      "description": "This is an embedded message."
    }
  ],
  "attachments": [
    {
      "id": 0,
      "description": "Image of a cute little cat",
      "filename": "myfilename.png"
    }
  ]
}

I would answer to the thing szurubooru sends also 403 cause its an unexpected input.