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

Allow to specify a different URL base for Discord hook #11124

Open
2 of 7 tasks
luwol03 opened this issue Apr 18, 2020 · 9 comments
Open
2 of 7 tasks

Allow to specify a different URL base for Discord hook #11124

luwol03 opened this issue Apr 18, 2020 · 9 comments
Labels
type/enhancement An improvement of existing functionality

Comments

@luwol03
Copy link

luwol03 commented Apr 18, 2020

  • Gitea version (or commit ref): commit: 2cb5878
  • Git version: 2.20.1
  • Operating system: Debian buster
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

problem

When I try to use a discord webhook, I always get a status code 400 with the body {"embeds": ["0"]}. Then I tried to analyze what this is due to.

problem solving approach

I discussed this on the gitea discord server with @6543#1089. https://discordapp.com/channels/322538954119184384/357627248095789056/700457572599201855 then I asked @6543#1089 to try it on him, which worked fine, and send me the result. So header and body. Then I started to compare the two and found out that they only differ in ID and author/repo data. Then I made the requests manually with curl. His header with my body did not work. But my header with his body. So I compared the body and changed one line until I found the culprit, or three! Discord has a problem with hostnames. I had configured my gitea instance in app.ini to use hostnames. @6543#1089 on the other hand, specified the IP. So it worked for him. So I just entered something different in the three fields (embeds[0].url; embeds[0].author.url and embeds[0].author.icon_url) and tested it with curl, and see how it works.

solution

So my idea would be, where you can enter the webhook url the username and the avatar url, just add three more fields for embeds[0].url; embeds[0].author.url and embeds[0].author.icon_url? So, that you can manually assign an url, an author url and author icon url, e.g. with a placeholder where the default values are already included.

@6543
Copy link
Member

6543 commented Apr 18, 2020

If we could figure it out if discord can resolve gitea's hostname and use ip or hostname based on this dessision it would not add more complexity or a simple option to "Ignore Hostname" witch would result in an embeds object with empty url fields?

@luwol03
Copy link
Author

luwol03 commented Apr 19, 2020

This is also an option, but I think if you can assign it individually, you can use e.g. pictures that you have uploaded on the internet.

@guillep2k
Copy link
Member

Sorry, where is this IP/hostname field located? Can you post an example request made with curl? (or two)

@guillep2k guillep2k added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Apr 21, 2020
@luwol03
Copy link
Author

luwol03 commented Apr 21, 2020

In my gitea instance the ROOT_URL in app.ini is set to the hostname. For discord this is probably a problem! This is the body that does not work:

{
  "wait": false,
  "content": "",
  "username": "Gitea",
  "avatar_url": "https://s.gitea.com/img/favicon.png",
  "tts": false,
  "embeds": [
    {
      "title": "[username/Test:master] 1 new commit",
      "description": "[2a3866e](https://myhostname:3000/username/Test/commit/2a3866e1b19805c2e24637d7452158aa995e0ecd) added random stuff",
      "url": "https://myhostname:3000/username/Test/commit/2a3866e1b19805c2e24637d7452158aa995e0ecd",
      "color": 1754624,
      "footer": {
        "text": ""
      },
      "author": {
        "name": "username",
        "url": "https://myhostname:3000/username",
        "icon_url": "https://myhostname:3000/user/avatar/username/-1"
      },
      "fields": null
    }
  ]
}

because I get a 400 status code with the body

{"embeds": ["0"]}

back! But if I change the hostnames to some other reachable dns names or ip addresses:

{
  "wait": false,
  "content": "",
  "username": "Gitea",
  "avatar_url": "https://s.gitea.com/img/favicon.png",
  "tts": false,
  "embeds": [
    {
      "title": "[username/Test:master] 1 new commit",
      "description": "[2a3866e](https://myhostname:3000/username/Test/commit/2a3866e1b19805c2e24637d7452158aa995e0ecd) added random stuff",
      "url": "https://gitea.com", ## This line
      "color": 1754624,
      "footer": {
        "text": ""
      },
      "author": {
        "name": "username",
        "url": "https://gitea.io",  ## This line
        "icon_url": "https://img.icons8.com/pastel-glyph/2x/worldwide-location.png" ## This line
      },
      "fields": null
    }
  ]
}

I get back a 204 status code! And my idea would be, that you put one extra fields and one checkbox on the page, where you create webhook at gitea. Because then you can upload your own pictures on the internet and use them in discord! Here is an example of me!
image
I hope that's made it clearer.

@guillep2k
Copy link
Member

Much clear! Thanks.

@guillep2k guillep2k added type/enhancement An improvement of existing functionality and removed issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail labels Apr 22, 2020
@guillep2k guillep2k changed the title Discord webhook error Allow to specify a different URL base for Discord hook Apr 22, 2020
@stale
Copy link

stale bot commented Jun 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale stale bot added the issue/stale label Jun 21, 2020
@luwol03
Copy link
Author

luwol03 commented Jun 21, 2020

It's applicable!

@stale stale bot removed the issue/stale label Jun 21, 2020
@stale
Copy link

stale bot commented Aug 23, 2020

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale stale bot added the issue/stale label Aug 23, 2020
@6543
Copy link
Member

6543 commented Aug 23, 2020

Ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants