forgejo/services/webhook
Gusted 389b32f51a feat: make upload URL compatible with GitHub API (#9285)
Adds new a function, `AcceptsGithubResponse`, to the API router context struct to check if the requests accepts a Github response. Although Forgejo API will never be compatible with the Github API, historically Forgejo's API has been designed to follow that of Github closely and we know that a lot of tooling that uses the Github API can be used against the Forgejo API with little to no problem.

As a meet in the middle solution, this function can be used to respond with a more appropriate response that follows the Github API. This allows Forgejo to avoid breaking compatibility with existing users of the API and allows the API to be oh so slightly more compatible with that of Github for API clients that expect a Github response.

Because the `upload_url` field was added purely to match the Github API (forgejo/forgejo#580), it is fair to actually make it compatible with how the Github API intended it to be and that is by adding `{?name,label}` which is used by Github's Oktokit.

Only add `{?name,label}` when Forgejo knows the request accepts a Github response. This avoids breaking the API compatibility with non-Github API  clients.

Resolves Codeberg/Community#2132

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9285
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
2025-09-15 15:53:35 +02:00
..
shared Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
sourcehut chore: replace gopkg.in/yaml.v3 with go.yaml.in/yaml/v3 (#8956) 2025-08-20 15:31:12 +02:00
TestPushCommits feat: add commit limit for webhook payload (#6797) 2025-02-07 19:26:50 +00:00
default.go feat(ui): redesign migration selection screen (#6795) 2025-04-19 13:51:35 +00:00
default_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
deliver.go chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
deliver_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
dingtalk.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
dingtalk_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
discord.go [gitea] week 2025-19 cherry pick (gitea/main -> forgejo) (#7909) 2025-06-27 13:59:07 +02:00
discord_test.go Fix discord webhook 400 status code when description limit is exceeded (#34084) 2025-04-07 18:27:08 +02:00
feishu.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
feishu_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
general.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
general_test.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
gogs.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
main_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
matrix.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
matrix_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
msteams.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
msteams_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
notifier.go feat: make upload URL compatible with GitHub API (#9285) 2025-09-15 15:53:35 +02:00
notifier_test.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
packagist.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
packagist_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
slack.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
slack_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
telegram.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
telegram_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
webhook.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
webhook_test.go chore: QoL improvements to tests (#7917) 2025-05-21 15:45:56 +02:00
wechatwork.go Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00