|
|
@ -11,7 +11,6 @@ import ( |
|
|
|
"code.gitea.io/gitea/models/perm" |
|
|
|
"code.gitea.io/gitea/models/perm" |
|
|
|
access_model "code.gitea.io/gitea/models/perm/access" |
|
|
|
access_model "code.gitea.io/gitea/models/perm/access" |
|
|
|
repo_model "code.gitea.io/gitea/models/repo" |
|
|
|
repo_model "code.gitea.io/gitea/models/repo" |
|
|
|
"code.gitea.io/gitea/models/unit" |
|
|
|
|
|
|
|
user_model "code.gitea.io/gitea/models/user" |
|
|
|
user_model "code.gitea.io/gitea/models/user" |
|
|
|
"code.gitea.io/gitea/modules/git" |
|
|
|
"code.gitea.io/gitea/modules/git" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
@ -50,7 +49,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(ctx context.Context, doer *user |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, issue.Poster, issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster) |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
if err = issue.LoadPullRequest(ctx); err != nil { |
|
|
|
if err = issue.LoadPullRequest(ctx); err != nil { |
|
|
@ -62,7 +61,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(ctx context.Context, doer *user |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -70,7 +69,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(ctx context.Context, doer *user |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Action: api.HookIssueLabelCleared, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -80,13 +79,13 @@ func (m *webhookNotifier) NotifyIssueClearLabels(ctx context.Context, doer *user |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyForkRepository(ctx context.Context, doer *user_model.User, oldRepo, repo *repo_model.Repository) { |
|
|
|
func (m *webhookNotifier) NotifyForkRepository(ctx context.Context, doer *user_model.User, oldRepo, repo *repo_model.Repository) { |
|
|
|
oldMode, _ := access_model.AccessLevel(ctx, doer, oldRepo) |
|
|
|
oldPermission, _ := access_model.GetUserRepoPermission(ctx, oldRepo, doer) |
|
|
|
mode, _ := access_model.AccessLevel(ctx, doer, repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, repo, doer) |
|
|
|
|
|
|
|
|
|
|
|
// forked webhook
|
|
|
|
// forked webhook
|
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: oldRepo}, webhook_module.HookEventFork, &api.ForkPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: oldRepo}, webhook_module.HookEventFork, &api.ForkPayload{ |
|
|
|
Forkee: convert.ToRepo(ctx, oldRepo, oldMode), |
|
|
|
Forkee: convert.ToRepo(ctx, oldRepo, oldPermission), |
|
|
|
Repo: convert.ToRepo(ctx, repo, mode), |
|
|
|
Repo: convert.ToRepo(ctx, repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
log.Error("PrepareWebhooks [repo_id: %d]: %v", oldRepo.ID, err) |
|
|
|
log.Error("PrepareWebhooks [repo_id: %d]: %v", oldRepo.ID, err) |
|
|
@ -98,7 +97,7 @@ func (m *webhookNotifier) NotifyForkRepository(ctx context.Context, doer *user_m |
|
|
|
if u.IsOrganization() { |
|
|
|
if u.IsOrganization() { |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Repository: convert.ToRepo(ctx, repo, perm.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Organization: convert.ToUser(ctx, u, nil), |
|
|
|
Organization: convert.ToUser(ctx, u, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
@ -111,7 +110,7 @@ func (m *webhookNotifier) NotifyCreateRepository(ctx context.Context, doer, u *u |
|
|
|
// Add to hook queue for created repo after session commit.
|
|
|
|
// Add to hook queue for created repo after session commit.
|
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Repository: convert.ToRepo(ctx, repo, perm.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Organization: convert.ToUser(ctx, u, nil), |
|
|
|
Organization: convert.ToUser(ctx, u, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
@ -122,7 +121,7 @@ func (m *webhookNotifier) NotifyCreateRepository(ctx context.Context, doer, u *u |
|
|
|
func (m *webhookNotifier) NotifyDeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) { |
|
|
|
func (m *webhookNotifier) NotifyDeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) { |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
Action: api.HookRepoDeleted, |
|
|
|
Action: api.HookRepoDeleted, |
|
|
|
Repository: convert.ToRepo(ctx, repo, perm.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Organization: convert.ToUser(ctx, repo.MustOwner(ctx), nil), |
|
|
|
Organization: convert.ToUser(ctx, repo.MustOwner(ctx), nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
@ -134,7 +133,7 @@ func (m *webhookNotifier) NotifyMigrateRepository(ctx context.Context, doer, u * |
|
|
|
// Add to hook queue for created repo after session commit.
|
|
|
|
// Add to hook queue for created repo after session commit.
|
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventRepository, &api.RepositoryPayload{ |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Action: api.HookRepoCreated, |
|
|
|
Repository: convert.ToRepo(ctx, repo, perm.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Organization: convert.ToUser(ctx, u, nil), |
|
|
|
Organization: convert.ToUser(ctx, u, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
@ -144,7 +143,7 @@ func (m *webhookNotifier) NotifyMigrateRepository(ctx context.Context, doer, u * |
|
|
|
|
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, assignee *user_model.User, removed bool, comment *issues_model.Comment) { |
|
|
|
func (m *webhookNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, assignee *user_model.User, removed bool, comment *issues_model.Comment) { |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
mode, _ := access_model.AccessLevelUnit(ctx, doer, issue.Repo, unit.TypePullRequests) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, doer) |
|
|
|
|
|
|
|
|
|
|
|
if err := issue.LoadPullRequest(ctx); err != nil { |
|
|
|
if err := issue.LoadPullRequest(ctx); err != nil { |
|
|
|
log.Error("LoadPullRequest failed: %v", err) |
|
|
|
log.Error("LoadPullRequest failed: %v", err) |
|
|
@ -153,7 +152,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *u |
|
|
|
apiPullRequest := &api.PullRequestPayload{ |
|
|
|
apiPullRequest := &api.PullRequestPayload{ |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
} |
|
|
|
} |
|
|
|
if removed { |
|
|
|
if removed { |
|
|
@ -167,11 +166,11 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *u |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
mode, _ := access_model.AccessLevelUnit(ctx, doer, issue.Repo, unit.TypeIssues) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, doer) |
|
|
|
apiIssue := &api.IssuePayload{ |
|
|
|
apiIssue := &api.IssuePayload{ |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
} |
|
|
|
} |
|
|
|
if removed { |
|
|
|
if removed { |
|
|
@ -188,7 +187,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *u |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyIssueChangeTitle(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldTitle string) { |
|
|
|
func (m *webhookNotifier) NotifyIssueChangeTitle(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldTitle string) { |
|
|
|
mode, _ := access_model.AccessLevel(ctx, issue.Poster, issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster) |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
if err = issue.LoadPullRequest(ctx); err != nil { |
|
|
|
if err = issue.LoadPullRequest(ctx); err != nil { |
|
|
@ -204,7 +203,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(ctx context.Context, doer *user |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -217,7 +216,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(ctx context.Context, doer *user |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -228,7 +227,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(ctx context.Context, doer *user |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *user_model.User, commitID string, issue *issues_model.Issue, actionComment *issues_model.Comment, isClosed bool) { |
|
|
|
func (m *webhookNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *user_model.User, commitID string, issue *issues_model.Issue, actionComment *issues_model.Comment, isClosed bool) { |
|
|
|
mode, _ := access_model.AccessLevel(ctx, issue.Poster, issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster) |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
if err = issue.LoadPullRequest(ctx); err != nil { |
|
|
|
if err = issue.LoadPullRequest(ctx); err != nil { |
|
|
@ -239,7 +238,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *use |
|
|
|
apiPullRequest := &api.PullRequestPayload{ |
|
|
|
apiPullRequest := &api.PullRequestPayload{ |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
CommitID: commitID, |
|
|
|
CommitID: commitID, |
|
|
|
} |
|
|
|
} |
|
|
@ -253,7 +252,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *use |
|
|
|
apiIssue := &api.IssuePayload{ |
|
|
|
apiIssue := &api.IssuePayload{ |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
CommitID: commitID, |
|
|
|
CommitID: commitID, |
|
|
|
} |
|
|
|
} |
|
|
@ -279,12 +278,12 @@ func (m *webhookNotifier) NotifyNewIssue(ctx context.Context, issue *issues_mode |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, issue.Poster, issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster) |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssues, &api.IssuePayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssues, &api.IssuePayload{ |
|
|
|
Action: api.HookIssueOpened, |
|
|
|
Action: api.HookIssueOpened, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, issue.Poster, nil), |
|
|
|
Sender: convert.ToUser(ctx, issue.Poster, nil), |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
log.Error("PrepareWebhooks: %v", err) |
|
|
|
log.Error("PrepareWebhooks: %v", err) |
|
|
@ -305,12 +304,12 @@ func (m *webhookNotifier) NotifyNewPullRequest(ctx context.Context, pull *issues |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, pull.Issue.Poster, pull.Issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, pull.Issue.Repo, pull.Issue.Poster) |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: pull.Issue.Repo}, webhook_module.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: pull.Issue.Repo}, webhook_module.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueOpened, |
|
|
|
Action: api.HookIssueOpened, |
|
|
|
Index: pull.Issue.Index, |
|
|
|
Index: pull.Issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, pull, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, pull, nil), |
|
|
|
Repository: convert.ToRepo(ctx, pull.Issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, pull.Issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, pull.Issue.Poster, nil), |
|
|
|
Sender: convert.ToUser(ctx, pull.Issue.Poster, nil), |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
log.Error("PrepareWebhooks: %v", err) |
|
|
|
log.Error("PrepareWebhooks: %v", err) |
|
|
@ -323,7 +322,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(ctx context.Context, doer *us |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, issue.Poster, issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster) |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
if err := issue.LoadPullRequest(ctx); err != nil { |
|
|
|
if err := issue.LoadPullRequest(ctx); err != nil { |
|
|
@ -339,7 +338,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(ctx context.Context, doer *us |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -352,7 +351,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(ctx context.Context, doer *us |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -383,7 +382,7 @@ func (m *webhookNotifier) NotifyUpdateComment(ctx context.Context, doer *user_mo |
|
|
|
eventType = webhook_module.HookEventIssueComment |
|
|
|
eventType = webhook_module.HookEventIssueComment |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, doer, c.Issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, c.Issue.Repo, doer) |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: c.Issue.Repo}, eventType, &api.IssueCommentPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: c.Issue.Repo}, eventType, &api.IssueCommentPayload{ |
|
|
|
Action: api.HookIssueCommentEdited, |
|
|
|
Action: api.HookIssueCommentEdited, |
|
|
|
Issue: convert.ToAPIIssue(ctx, c.Issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, c.Issue), |
|
|
@ -393,7 +392,7 @@ func (m *webhookNotifier) NotifyUpdateComment(ctx context.Context, doer *user_mo |
|
|
|
From: oldContent, |
|
|
|
From: oldContent, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
Repository: convert.ToRepo(ctx, c.Issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, c.Issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
IsPull: c.Issue.IsPull, |
|
|
|
IsPull: c.Issue.IsPull, |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
@ -411,12 +410,12 @@ func (m *webhookNotifier) NotifyCreateIssueComment(ctx context.Context, doer *us |
|
|
|
eventType = webhook_module.HookEventIssueComment |
|
|
|
eventType = webhook_module.HookEventIssueComment |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, doer, repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, repo, doer) |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, eventType, &api.IssueCommentPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, eventType, &api.IssueCommentPayload{ |
|
|
|
Action: api.HookIssueCommentCreated, |
|
|
|
Action: api.HookIssueCommentCreated, |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Comment: convert.ToComment(ctx, comment), |
|
|
|
Comment: convert.ToComment(ctx, comment), |
|
|
|
Repository: convert.ToRepo(ctx, repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
IsPull: issue.IsPull, |
|
|
|
IsPull: issue.IsPull, |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
@ -448,12 +447,12 @@ func (m *webhookNotifier) NotifyDeleteComment(ctx context.Context, doer *user_mo |
|
|
|
eventType = webhook_module.HookEventIssueComment |
|
|
|
eventType = webhook_module.HookEventIssueComment |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, doer, comment.Issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, comment.Issue.Repo, doer) |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: comment.Issue.Repo}, eventType, &api.IssueCommentPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: comment.Issue.Repo}, eventType, &api.IssueCommentPayload{ |
|
|
|
Action: api.HookIssueCommentDeleted, |
|
|
|
Action: api.HookIssueCommentDeleted, |
|
|
|
Issue: convert.ToAPIIssue(ctx, comment.Issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, comment.Issue), |
|
|
|
Comment: convert.ToComment(ctx, comment), |
|
|
|
Comment: convert.ToComment(ctx, comment), |
|
|
|
Repository: convert.ToRepo(ctx, comment.Issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
IsPull: comment.Issue.IsPull, |
|
|
|
IsPull: comment.Issue.IsPull, |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
@ -465,7 +464,7 @@ func (m *webhookNotifier) NotifyNewWikiPage(ctx context.Context, doer *user_mode |
|
|
|
// Add to hook queue for created wiki page.
|
|
|
|
// Add to hook queue for created wiki page.
|
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventWiki, &api.WikiPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventWiki, &api.WikiPayload{ |
|
|
|
Action: api.HookWikiCreated, |
|
|
|
Action: api.HookWikiCreated, |
|
|
|
Repository: convert.ToRepo(ctx, repo, perm.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Page: page, |
|
|
|
Page: page, |
|
|
|
Comment: comment, |
|
|
|
Comment: comment, |
|
|
@ -478,7 +477,7 @@ func (m *webhookNotifier) NotifyEditWikiPage(ctx context.Context, doer *user_mod |
|
|
|
// Add to hook queue for edit wiki page.
|
|
|
|
// Add to hook queue for edit wiki page.
|
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventWiki, &api.WikiPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventWiki, &api.WikiPayload{ |
|
|
|
Action: api.HookWikiEdited, |
|
|
|
Action: api.HookWikiEdited, |
|
|
|
Repository: convert.ToRepo(ctx, repo, perm.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Page: page, |
|
|
|
Page: page, |
|
|
|
Comment: comment, |
|
|
|
Comment: comment, |
|
|
@ -491,7 +490,7 @@ func (m *webhookNotifier) NotifyDeleteWikiPage(ctx context.Context, doer *user_m |
|
|
|
// Add to hook queue for edit wiki page.
|
|
|
|
// Add to hook queue for edit wiki page.
|
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventWiki, &api.WikiPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventWiki, &api.WikiPayload{ |
|
|
|
Action: api.HookWikiDeleted, |
|
|
|
Action: api.HookWikiDeleted, |
|
|
|
Repository: convert.ToRepo(ctx, repo, perm.AccessModeOwner), |
|
|
|
Repository: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Page: page, |
|
|
|
Page: page, |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
@ -514,7 +513,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(ctx context.Context, doer *use |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, issue.Poster, issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster) |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
if err = issue.LoadPullRequest(ctx); err != nil { |
|
|
|
if err = issue.LoadPullRequest(ctx); err != nil { |
|
|
|
log.Error("loadPullRequest: %v", err) |
|
|
|
log.Error("loadPullRequest: %v", err) |
|
|
@ -528,7 +527,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(ctx context.Context, doer *use |
|
|
|
Action: api.HookIssueLabelUpdated, |
|
|
|
Action: api.HookIssueLabelUpdated, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, perm.AccessModeNone), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -536,7 +535,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(ctx context.Context, doer *use |
|
|
|
Action: api.HookIssueLabelUpdated, |
|
|
|
Action: api.HookIssueLabelUpdated, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -559,7 +558,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(ctx context.Context, doer * |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, doer, issue.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, doer) |
|
|
|
if issue.IsPull { |
|
|
|
if issue.IsPull { |
|
|
|
err = issue.PullRequest.LoadIssue(ctx) |
|
|
|
err = issue.PullRequest.LoadIssue(ctx) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -570,7 +569,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(ctx context.Context, doer * |
|
|
|
Action: hookAction, |
|
|
|
Action: hookAction, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -578,7 +577,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(ctx context.Context, doer * |
|
|
|
Action: hookAction, |
|
|
|
Action: hookAction, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Issue: convert.ToAPIIssue(ctx, issue), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -603,7 +602,7 @@ func (m *webhookNotifier) NotifyPushCommits(ctx context.Context, pusher *user_mo |
|
|
|
Commits: apiCommits, |
|
|
|
Commits: apiCommits, |
|
|
|
TotalCommits: commits.Len, |
|
|
|
TotalCommits: commits.Len, |
|
|
|
HeadCommit: apiHeadCommit, |
|
|
|
HeadCommit: apiHeadCommit, |
|
|
|
Repo: convert.ToRepo(ctx, repo, perm.AccessModeOwner), |
|
|
|
Repo: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Pusher: apiPusher, |
|
|
|
Pusher: apiPusher, |
|
|
|
Sender: apiPusher, |
|
|
|
Sender: apiPusher, |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
@ -633,9 +632,9 @@ func (*webhookNotifier) NotifyMergePullRequest(ctx context.Context, doer *user_m |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, err := access_model.AccessLevel(ctx, doer, pr.Issue.Repo) |
|
|
|
permission, err := access_model.GetUserRepoPermission(ctx, pr.Issue.Repo, doer) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("models.AccessLevel: %v", err) |
|
|
|
log.Error("models.GetUserRepoPermission: %v", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -643,7 +642,7 @@ func (*webhookNotifier) NotifyMergePullRequest(ctx context.Context, doer *user_m |
|
|
|
apiPullRequest := &api.PullRequestPayload{ |
|
|
|
apiPullRequest := &api.PullRequestPayload{ |
|
|
|
Index: pr.Issue.Index, |
|
|
|
Index: pr.Issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, pr, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, pr, nil), |
|
|
|
Repository: convert.ToRepo(ctx, pr.Issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, pr.Issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Action: api.HookIssueClosed, |
|
|
|
Action: api.HookIssueClosed, |
|
|
|
} |
|
|
|
} |
|
|
@ -661,7 +660,7 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(ctx context.Contex |
|
|
|
|
|
|
|
|
|
|
|
issue := pr.Issue |
|
|
|
issue := pr.Issue |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, issue.Poster, issue.Repo) |
|
|
|
mode, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster) |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventPullRequest, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Action: api.HookIssueEdited, |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
@ -699,16 +698,16 @@ func (m *webhookNotifier) NotifyPullRequestReview(ctx context.Context, pr *issue |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, err := access_model.AccessLevel(ctx, review.Issue.Poster, review.Issue.Repo) |
|
|
|
permission, err := access_model.GetUserRepoPermission(ctx, review.Issue.Repo, review.Issue.Poster) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("models.AccessLevel: %v", err) |
|
|
|
log.Error("models.GetUserRepoPermission: %v", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: review.Issue.Repo}, reviewHookType, &api.PullRequestPayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: review.Issue.Repo}, reviewHookType, &api.PullRequestPayload{ |
|
|
|
Action: api.HookIssueReviewed, |
|
|
|
Action: api.HookIssueReviewed, |
|
|
|
Index: review.Issue.Index, |
|
|
|
Index: review.Issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, pr, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, pr, nil), |
|
|
|
Repository: convert.ToRepo(ctx, review.Issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, review.Issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, review.Reviewer, nil), |
|
|
|
Sender: convert.ToUser(ctx, review.Reviewer, nil), |
|
|
|
Review: &api.ReviewPayload{ |
|
|
|
Review: &api.ReviewPayload{ |
|
|
|
Type: string(reviewHookType), |
|
|
|
Type: string(reviewHookType), |
|
|
@ -724,7 +723,7 @@ func (m *webhookNotifier) NotifyPullRequestReviewRequest(ctx context.Context, do |
|
|
|
log.Warn("NotifyPullRequestReviewRequest: issue is not a pull request: %v", issue.ID) |
|
|
|
log.Warn("NotifyPullRequestReviewRequest: issue is not a pull request: %v", issue.ID) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
mode, _ := access_model.AccessLevelUnit(ctx, doer, issue.Repo, unit.TypePullRequests) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, doer) |
|
|
|
if err := issue.LoadPullRequest(ctx); err != nil { |
|
|
|
if err := issue.LoadPullRequest(ctx); err != nil { |
|
|
|
log.Error("LoadPullRequest failed: %v", err) |
|
|
|
log.Error("LoadPullRequest failed: %v", err) |
|
|
|
return |
|
|
|
return |
|
|
@ -733,7 +732,7 @@ func (m *webhookNotifier) NotifyPullRequestReviewRequest(ctx context.Context, do |
|
|
|
Index: issue.Index, |
|
|
|
Index: issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), |
|
|
|
RequestedReviewer: convert.ToUser(ctx, reviewer, nil), |
|
|
|
RequestedReviewer: convert.ToUser(ctx, reviewer, nil), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, issue.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
} |
|
|
|
} |
|
|
|
if isRequest { |
|
|
|
if isRequest { |
|
|
@ -749,7 +748,7 @@ func (m *webhookNotifier) NotifyPullRequestReviewRequest(ctx context.Context, do |
|
|
|
|
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyCreateRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName, refID string) { |
|
|
|
func (m *webhookNotifier) NotifyCreateRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName, refID string) { |
|
|
|
apiPusher := convert.ToUser(ctx, pusher, nil) |
|
|
|
apiPusher := convert.ToUser(ctx, pusher, nil) |
|
|
|
apiRepo := convert.ToRepo(ctx, repo, perm.AccessModeNone) |
|
|
|
apiRepo := convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeNone}) |
|
|
|
refName := refFullName.ShortName() |
|
|
|
refName := refFullName.ShortName() |
|
|
|
|
|
|
|
|
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventCreate, &api.CreatePayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventCreate, &api.CreatePayload{ |
|
|
@ -777,7 +776,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(ctx context.Context, doe |
|
|
|
Action: api.HookIssueSynchronized, |
|
|
|
Action: api.HookIssueSynchronized, |
|
|
|
Index: pr.Issue.Index, |
|
|
|
Index: pr.Issue.Index, |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, pr, nil), |
|
|
|
PullRequest: convert.ToAPIPullRequest(ctx, pr, nil), |
|
|
|
Repository: convert.ToRepo(ctx, pr.Issue.Repo, perm.AccessModeNone), |
|
|
|
Repository: convert.ToRepo(ctx, pr.Issue.Repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err) |
|
|
|
log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err) |
|
|
@ -786,7 +785,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(ctx context.Context, doe |
|
|
|
|
|
|
|
|
|
|
|
func (m *webhookNotifier) NotifyDeleteRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName) { |
|
|
|
func (m *webhookNotifier) NotifyDeleteRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName) { |
|
|
|
apiPusher := convert.ToUser(ctx, pusher, nil) |
|
|
|
apiPusher := convert.ToUser(ctx, pusher, nil) |
|
|
|
apiRepo := convert.ToRepo(ctx, repo, perm.AccessModeNone) |
|
|
|
apiRepo := convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}) |
|
|
|
refName := refFullName.ShortName() |
|
|
|
refName := refFullName.ShortName() |
|
|
|
|
|
|
|
|
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventDelete, &api.DeletePayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventDelete, &api.DeletePayload{ |
|
|
@ -806,11 +805,11 @@ func sendReleaseHook(ctx context.Context, doer *user_model.User, rel *repo_model |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mode, _ := access_model.AccessLevel(ctx, doer, rel.Repo) |
|
|
|
permission, _ := access_model.GetUserRepoPermission(ctx, rel.Repo, doer) |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: rel.Repo}, webhook_module.HookEventRelease, &api.ReleasePayload{ |
|
|
|
if err := PrepareWebhooks(ctx, EventSource{Repository: rel.Repo}, webhook_module.HookEventRelease, &api.ReleasePayload{ |
|
|
|
Action: action, |
|
|
|
Action: action, |
|
|
|
Release: convert.ToRelease(ctx, rel), |
|
|
|
Release: convert.ToRelease(ctx, rel), |
|
|
|
Repository: convert.ToRepo(ctx, rel.Repo, mode), |
|
|
|
Repository: convert.ToRepo(ctx, rel.Repo, permission), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
Sender: convert.ToUser(ctx, doer, nil), |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
log.Error("PrepareWebhooks: %v", err) |
|
|
|
log.Error("PrepareWebhooks: %v", err) |
|
|
@ -845,7 +844,7 @@ func (m *webhookNotifier) NotifySyncPushCommits(ctx context.Context, pusher *use |
|
|
|
Commits: apiCommits, |
|
|
|
Commits: apiCommits, |
|
|
|
TotalCommits: commits.Len, |
|
|
|
TotalCommits: commits.Len, |
|
|
|
HeadCommit: apiHeadCommit, |
|
|
|
HeadCommit: apiHeadCommit, |
|
|
|
Repo: convert.ToRepo(ctx, repo, perm.AccessModeOwner), |
|
|
|
Repo: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}), |
|
|
|
Pusher: apiPusher, |
|
|
|
Pusher: apiPusher, |
|
|
|
Sender: apiPusher, |
|
|
|
Sender: apiPusher, |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|