parent
96918a442b
commit
b05e178138
2 changed files with 17 additions and 23 deletions
|
@ -99,30 +99,26 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
|
||||||
|
|
||||||
func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
// Add to hook queue for created repo after session commit.
|
// Add to hook queue for created repo after session commit.
|
||||||
if u.IsOrganization() {
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
||||||
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
Action: api.HookRepoCreated,
|
||||||
Action: api.HookRepoCreated,
|
Repository: repo.APIFormat(models.AccessModeOwner),
|
||||||
Repository: repo.APIFormat(models.AccessModeOwner),
|
Organization: u.APIFormat(),
|
||||||
Organization: u.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
Sender: doer.APIFormat(),
|
}); err != nil {
|
||||||
}); err != nil {
|
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
||||||
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) {
|
func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) {
|
||||||
u := repo.MustOwner()
|
u := repo.MustOwner()
|
||||||
|
|
||||||
if u.IsOrganization() {
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
||||||
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
Action: api.HookRepoDeleted,
|
||||||
Action: api.HookRepoDeleted,
|
Repository: repo.APIFormat(models.AccessModeOwner),
|
||||||
Repository: repo.APIFormat(models.AccessModeOwner),
|
Organization: u.APIFormat(),
|
||||||
Organization: u.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
Sender: doer.APIFormat(),
|
}); err != nil {
|
||||||
}); err != nil {
|
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
||||||
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,11 @@ func DeleteRepository(doer *models.User, repo *models.Repository) error {
|
||||||
log.Error("CloseRepoBranchesPulls failed: %v", err)
|
log.Error("CloseRepoBranchesPulls failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := models.DeleteRepository(doer, repo.OwnerID, repo.ID); err != nil {
|
// If the repo itself has webhooks, we need to trigger them before deleting it...
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
notification.NotifyDeleteRepository(doer, repo)
|
notification.NotifyDeleteRepository(doer, repo)
|
||||||
|
|
||||||
return nil
|
err := models.DeleteRepository(doer, repo.OwnerID, repo.ID)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// PushCreateRepo creates a repository when a new repository is pushed to an appropriate namespace
|
// PushCreateRepo creates a repository when a new repository is pushed to an appropriate namespace
|
||||||
|
|
Reference in a new issue