add organization webhook support #14784

Open
a1012112796 wants to merge 11 commits from a1012112796/hooks into main
a1012112796 commented 2021-02-24 07:54:40 +00:00 (Migrated from github.com)
it's same with gh, ref: https://docs.github.com/en/github-ae@latest/developers/webhooks-and-events/webhook-events-and-payloads#organization https://docs.github.com/en/github-ae@latest/developers/webhooks-and-events/webhook-events-and-payloads#team https://docs.github.com/en/github-ae@latest/developers/webhooks-and-events/webhook-events-and-payloads#membership
adelowo reviewed 2021-06-23 22:28:06 +00:00
@ -627,10 +663,38 @@ func (h HookEventType) Event() string {
return "repository"
case HookEventRelease:
Contributor
  HookEventLevelRepo HookEventLevel = iota + 1

iota along makes it zero and it feels kind of weird seeing a valid state as 0

```suggestion HookEventLevelRepo HookEventLevel = iota + 1 ``` iota along makes it zero and it feels kind of weird seeing a valid state as 0
@ -761,1 +826,4 @@
// FindOrgUndeliveredHookTasks finds the undelivered hook tasks of an organisation
func FindOrgUndeliveredHookTasks(orgID int64) ([]*HookTask, error) {
tasks := make([]*HookTask, 0, 5)
Contributor
// FindOrgUndeliveredHookTasks finds the undelivered hook tasks of an organisation
```suggestion // FindOrgUndeliveredHookTasks finds the undelivered hook tasks of an organisation ```
zeripath reviewed 2021-06-24 19:52:08 +00:00
@ -92,3 +92,3 @@
}
// PrepareWebhook adds special webhook to task queue for given payload.
// PrepareWebhook adds special repository webhook to task queue for given payload.
Contributor

It probably would be simpler to have:

func PrepareWebhook(w *models.Webhook, repo *models.Repository, event models.HookEventType, p api.Payloader) error {
  return PrepareRepoOrgWebhook(w, repo, nil, event, p)
}

func PrepareOrgWebhook(w *models.Webhook, org *models.User, event models.HookEventType, p api.Payloader) error {
  return PrepareRepoOrgWebhook(w, nil, org, event, p)
}

func PrepareRepoOrgWebhook(w *models.Webhook, repo *models.Repository, org *models.User, event models.HookEventType, p api.Payloader) error {
 ...
}

Then you would need most of the changes in modules/notification/webhook/webhook.go and elsewhere.

It probably would be simpler to have: ```go func PrepareWebhook(w *models.Webhook, repo *models.Repository, event models.HookEventType, p api.Payloader) error { return PrepareRepoOrgWebhook(w, repo, nil, event, p) } func PrepareOrgWebhook(w *models.Webhook, org *models.User, event models.HookEventType, p api.Payloader) error { return PrepareRepoOrgWebhook(w, nil, org, event, p) } func PrepareRepoOrgWebhook(w *models.Webhook, repo *models.Repository, org *models.User, event models.HookEventType, p api.Payloader) error { ... } ``` Then you would need most of the changes in modules/notification/webhook/webhook.go and elsewhere.
lunny reviewed 2021-06-26 11:02:36 +00:00

You don't need that, since webhook table has already the column.

You don't need that, since webhook table has already the column.
lunny reviewed 2021-06-26 11:03:35 +00:00
lunny requested changes 2021-06-26 11:06:06 +00:00
lunny left a comment

per my comments

per my comments
a1012112796 (Migrated from github.com) reviewed 2021-07-01 03:32:41 +00:00
a1012112796 (Migrated from github.com) commented 2021-07-01 03:32:40 +00:00

@lunny But then how to find undelivered orgs task?
see services/webhook/deliver.go

@lunny But then how to find undelivered orgs task? see ``services/webhook/deliver.go``
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/gitea#14784
No description provided.