more events
This commit is contained in:
parent
2563e6e8ef
commit
5a61d42a64
|
|
@ -1380,15 +1380,7 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
|
||||||
return fmt.Errorf("getOwnerTeam: %v", err)
|
return fmt.Errorf("getOwnerTeam: %v", err)
|
||||||
} else if err = t.addRepository(e, repo); err != nil {
|
} else if err = t.addRepository(e, repo); err != nil {
|
||||||
return fmt.Errorf("addRepository: %v", err)
|
return fmt.Errorf("addRepository: %v", err)
|
||||||
} else if err = prepareWebhooks(e, repo, HookEventRepository, &api.RepositoryPayload{
|
|
||||||
Action: api.HookRepoCreated,
|
|
||||||
Repository: repo.APIFormat(AccessModeOwner),
|
|
||||||
Organization: u.APIFormat(),
|
|
||||||
Sender: doer.APIFormat(),
|
|
||||||
}); err != nil {
|
|
||||||
return fmt.Errorf("prepareWebhooks: %v", err)
|
|
||||||
}
|
}
|
||||||
go HookQueue.Add(repo.ID)
|
|
||||||
} else {
|
} else {
|
||||||
// Organization automatically called this in addRepository method.
|
// Organization automatically called this in addRepository method.
|
||||||
if err = repo.recalculateAccesses(e); err != nil {
|
if err = repo.recalculateAccesses(e); err != nil {
|
||||||
|
|
@ -1398,8 +1390,6 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
|
||||||
|
|
||||||
if err = watchRepo(e, doer.ID, repo.ID, true); err != nil {
|
if err = watchRepo(e, doer.ID, repo.ID, true); err != nil {
|
||||||
return fmt.Errorf("watchRepo: %v", err)
|
return fmt.Errorf("watchRepo: %v", err)
|
||||||
} else if err = newRepoAction(e, u, repo); err != nil {
|
|
||||||
return fmt.Errorf("newRepoAction: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -110,3 +110,15 @@ func (r *actionNotifier) NotifyIssueChangeTitle(doer *models.User, issue *models
|
||||||
func (r *actionNotifier) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
func (r *actionNotifier) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
||||||
addedLabels []*models.Label, removedLabels []*models.Label) {
|
addedLabels []*models.Label, removedLabels []*models.Label) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *actionNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
if err := models.NewRepoAction(doer, repo); err != nil {
|
||||||
|
log.Error(4, "NewRepoAction [%d]: %v", repo.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *actionNotifier) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
if err := models.NewRepoAction(doer, repo); err != nil {
|
||||||
|
log.Error(4, "NewRepoAction [%d]: %v", repo.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,4 +31,6 @@ type Notifier interface {
|
||||||
NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string)
|
NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string)
|
||||||
NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
||||||
addedLabels []*models.Label, removedLabels []*models.Label)
|
addedLabels []*models.Label, removedLabels []*models.Label)
|
||||||
|
NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository)
|
||||||
|
NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,3 +88,9 @@ func (r *indexerNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
|
||||||
func (r *indexerNotifier) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
func (r *indexerNotifier) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
||||||
addedLabels []*models.Label, removedLabels []*models.Label) {
|
addedLabels []*models.Label, removedLabels []*models.Label) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *indexerNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *indexerNotifier) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,3 +87,9 @@ func (m *mailNotifier) NotifyIssueChangeTitle(doer *models.User, issue *models.I
|
||||||
func (m *mailNotifier) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
func (m *mailNotifier) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
||||||
addedLabels []*models.Label, removedLabels []*models.Label) {
|
addedLabels []*models.Label, removedLabels []*models.Label) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mailNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mailNotifier) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,3 +153,17 @@ func NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
||||||
notifier.NotifyIssueChangeLabels(doer, issue, addedLabels, removedLabels)
|
notifier.NotifyIssueChangeLabels(doer, issue, addedLabels, removedLabels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotifyCreateRepository notifies create repository to notifiers
|
||||||
|
func NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
for _, notifier := range notifiers {
|
||||||
|
notifier.NotifyCreateRepository(doer, u, repo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotifyMigrateRepository notifies create repository to notifiers
|
||||||
|
func NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
for _, notifier := range notifiers {
|
||||||
|
notifier.NotifyMigrateRepository(doer, u, repo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,3 +112,9 @@ func (ns *notificationService) NotifyIssueChangeTitle(doer *models.User, issue *
|
||||||
func (ns *notificationService) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
func (ns *notificationService) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
||||||
addedLabels []*models.Label, removedLabels []*models.Label) {
|
addedLabels []*models.Label, removedLabels []*models.Label) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ns *notificationService) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ns *notificationService) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -496,3 +496,29 @@ func (w *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode
|
||||||
go models.HookQueue.Add(issue.RepoID)
|
go models.HookQueue.Add(issue.RepoID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
if err := models.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
||||||
|
Action: api.HookRepoCreated,
|
||||||
|
Repository: repo.APIFormat(models.AccessModeOwner),
|
||||||
|
Organization: u.APIFormat(),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
}); err != nil {
|
||||||
|
log.Error(4, "PrepareWebhooks: %v", err)
|
||||||
|
} else {
|
||||||
|
go models.HookQueue.Add(repo.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *webhookNotifier) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
|
if err := models.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
||||||
|
Action: api.HookRepoCreated,
|
||||||
|
Repository: repo.APIFormat(models.AccessModeOwner),
|
||||||
|
Organization: u.APIFormat(),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
}); err != nil {
|
||||||
|
log.Error(4, "PrepareWebhooks: %v", err)
|
||||||
|
} else {
|
||||||
|
go models.HookQueue.Add(repo.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -187,8 +187,6 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
|
||||||
if repo != nil {
|
if repo != nil {
|
||||||
if err = models.DeleteRepository(ctx.User, ctx.User.ID, repo.ID); err != nil {
|
if err = models.DeleteRepository(ctx.User, ctx.User.ID, repo.ID); err != nil {
|
||||||
log.Error(4, "DeleteRepository: %v", err)
|
log.Error(4, "DeleteRepository: %v", err)
|
||||||
} else {
|
|
||||||
notification.NotifyDeleteRepository(ctx.User, repo)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.Error(500, "CreateRepository", err)
|
ctx.Error(500, "CreateRepository", err)
|
||||||
|
|
@ -196,6 +194,8 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notification.NotifyCreateRepository(ctx.User, owner, repo)
|
||||||
|
|
||||||
ctx.JSON(201, repo.APIFormat(models.AccessModeOwner))
|
ctx.JSON(201, repo.APIFormat(models.AccessModeOwner))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,8 +362,6 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
|
||||||
if repo != nil {
|
if repo != nil {
|
||||||
if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil {
|
if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil {
|
||||||
log.Error(4, "DeleteRepository: %v", errDelete)
|
log.Error(4, "DeleteRepository: %v", errDelete)
|
||||||
} else {
|
|
||||||
notification.NotifyDeleteRepository(ctx.User, repo)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.Error(500, "MigrateRepository", err)
|
ctx.Error(500, "MigrateRepository", err)
|
||||||
|
|
@ -371,6 +369,8 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName)
|
log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName)
|
||||||
|
|
||||||
|
notification.NotifyMigrateRepository(ctx.User, ctxUser, repo)
|
||||||
ctx.JSON(201, repo.APIFormat(models.AccessModeAdmin))
|
ctx.JSON(201, repo.APIFormat(models.AccessModeAdmin))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,8 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
|
||||||
AutoInit: form.AutoInit,
|
AutoInit: form.AutoInit,
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
notification.NotifyCreateRepository(ctx.User, ctxUser, repo)
|
||||||
|
|
||||||
log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
|
log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
|
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
|
||||||
return
|
return
|
||||||
|
|
@ -184,8 +186,6 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
|
||||||
if repo != nil {
|
if repo != nil {
|
||||||
if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil {
|
if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil {
|
||||||
log.Error(4, "DeleteRepository: %v", errDelete)
|
log.Error(4, "DeleteRepository: %v", errDelete)
|
||||||
} else {
|
|
||||||
notification.NotifyDeleteRepository(ctx.User, repo)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,6 +254,9 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Trace("Repository migrated [%d]: %s/%s", repo.ID, ctxUser.Name, form.RepoName)
|
log.Trace("Repository migrated [%d]: %s/%s", repo.ID, ctxUser.Name, form.RepoName)
|
||||||
|
|
||||||
|
notification.NotifyMigrateRepository(ctx.User, ctxUser, repo)
|
||||||
|
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + form.RepoName)
|
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + form.RepoName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -264,8 +267,6 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
|
||||||
if repo != nil {
|
if repo != nil {
|
||||||
if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil {
|
if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil {
|
||||||
log.Error(4, "DeleteRepository: %v", errDelete)
|
log.Error(4, "DeleteRepository: %v", errDelete)
|
||||||
} else {
|
|
||||||
notification.NotifyDeleteRepository(ctx.User, repo)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user