gitea/templates
Michael B. a90af22003
Let API create and edit system webhooks, attempt 2 (#33180)
This PR fixes inconsistencies between system and default webhooks in the
Gitea API. (See also #26418)
- A system webhook is a webhook that captures events for all
repositories.
- A default webhook is copied to a new repository when it is created. 

Before this PR `POST /api/v1/admin/hooks/` creates default webhooks (if
not configured otherwise) and `GET /api/v1/admin/hooks/` returns system
webhooks.

The PR introduces an optional query parameter to `GET
/api/v1/admin/hooks/` to enable selecting if either default, system or
both kind of webhooks should be retrieved. By default the flag is set to
return system webhooks keep current behaviour.

## Examples

### System Webhooks

#### Create

```
POST /api/v1/admin/hooks/

{
  "type": "gitea",
  "active": false,
  "branch_filter": "*",
  "events": [ "create", "..." ],
  "config": {
    "url": "http://...",
    "content_type": "json",
    "secret": "secret",
    "is_system_webhook": true // <-- controls hook type
  }
}
```

#### List
```
GET/api/v1/admin/hooks?type=system //type argument is optional here since it's the default
```

#### Others
The other relevant endpoints work as expected by referencing the hook by
id
```
GET /api/v1/admin/hooks/:id
PATCH /api/v1/admin/hooks/:id
DELETE /api/v1/admin/hooks/:id
```


### Default Webhooks

#### Create
```
POST /api/v1/admin/hooks/

{
  "type": "gitea",
  "active": false,
  "branch_filter": "*",
  "events": [ "create", "..." ],
  "config": {
    "url": "http://...",
    "content_type": "json",
    "secret": "secret",
    "is_system_webhook": false // optional, as false is the default value
  }
}
```

#### List
```
GET/api/v1/admin/hooks?type=default
```

#### Others
The other relevant endpoints work as expected by referencing the hook by
id
```
GET /api/v1/admin/hooks/:id
PATCH /api/v1/admin/hooks/:id
DELETE /api/v1/admin/hooks/:id
```
2025-01-13 17:17:39 +00:00
..
admin Remove some unnecessary template helpers (#33069) 2025-01-01 18:02:34 +08:00
api/packages/pypi
base Fix dropdown menu header and mobile view (#33108) 2025-01-05 21:20:22 +00:00
custom
devtest De-emphasize signed commits (#31160) 2024-12-28 04:18:30 +08:00
explore Refactor template ctx and render utils (#32422) 2024-11-05 14:04:26 +08:00
mail
org Fix form width (#33151) 2025-01-08 23:57:18 +08:00
package feat: link to nuget dependencies (#26554) 2025-01-01 19:07:10 +08:00
projects Refactor repo-projects.ts (#32892) 2024-12-19 08:37:12 +00:00
repo Refactor context RefName and RepoAssignment (#33226) 2025-01-13 01:07:05 +00:00
shared Fix bleve fuzziness search (#33078) 2025-01-03 00:32:02 +08:00
status Remove urls from translations (#31950) 2024-09-02 18:36:24 +00:00
swagger Let API create and edit system webhooks, attempt 2 (#33180) 2025-01-13 17:17:39 +00:00
user Fix form width (#33151) 2025-01-08 23:57:18 +08:00
webhook
home.tmpl Remove urls from translations (#31950) 2024-09-02 18:36:24 +00:00
install.tmpl Supplement and Improvement for #32558 (#32585) 2024-11-21 02:42:37 +00:00
post-install.tmpl Optimize the installation page (#32994) 2024-12-31 04:49:26 +00:00