summaryrefslogtreecommitdiffstats
path: root/modules/notification
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-12-02 22:38:30 +0100
committerGitHub <noreply@github.com>2020-12-02 16:38:30 -0500
commit7ac8a770e1086a50d1fc0a194fe0d7060036fb30 (patch)
treef3c9e4e92bd158c8ef506ea46163c2dd95a57cfa /modules/notification
parent2b4a08e9621e052845062ecd71ebfd37453c0383 (diff)
downloadgitea-7ac8a770e1086a50d1fc0a194fe0d7060036fb30.tar.gz
gitea-7ac8a770e1086a50d1fc0a194fe0d7060036fb30.zip
Move Repo APIFormat to convert package (#13787)
* Move Repo APIFormat to convert package * tweek
Diffstat (limited to 'modules/notification')
-rw-r--r--modules/notification/webhook/webhook.go72
1 files changed, 36 insertions, 36 deletions
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go
index bc21fb6113..4c9c213f18 100644
--- a/modules/notification/webhook/webhook.go
+++ b/modules/notification/webhook/webhook.go
@@ -52,7 +52,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
Action: api.HookIssueLabelCleared,
Index: issue.Index,
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
})
} else {
@@ -60,7 +60,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
Action: api.HookIssueLabelCleared,
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
})
}
@@ -75,8 +75,8 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
// forked webhook
if err := webhook_module.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{
- Forkee: oldRepo.APIFormat(oldMode),
- Repo: repo.APIFormat(mode),
+ Forkee: convert.ToRepo(oldRepo, oldMode),
+ Repo: convert.ToRepo(repo, mode),
Sender: convert.ToUser(doer, false, false),
}); err != nil {
log.Error("PrepareWebhooks [repo_id: %d]: %v", oldRepo.ID, err)
@@ -88,7 +88,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
if u.IsOrganization() {
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
Action: api.HookRepoCreated,
- Repository: repo.APIFormat(models.AccessModeOwner),
+ Repository: convert.ToRepo(repo, models.AccessModeOwner),
Organization: convert.ToUser(u, false, false),
Sender: convert.ToUser(doer, false, false),
}); err != nil {
@@ -101,7 +101,7 @@ func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.Us
// Add to hook queue for created repo after session commit.
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
Action: api.HookRepoCreated,
- Repository: repo.APIFormat(models.AccessModeOwner),
+ Repository: convert.ToRepo(repo, models.AccessModeOwner),
Organization: convert.ToUser(u, false, false),
Sender: convert.ToUser(doer, false, false),
}); err != nil {
@@ -114,7 +114,7 @@ func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
Action: api.HookRepoDeleted,
- Repository: repo.APIFormat(models.AccessModeOwner),
+ Repository: convert.ToRepo(repo, models.AccessModeOwner),
Organization: convert.ToUser(u, false, false),
Sender: convert.ToUser(doer, false, false),
}); err != nil {
@@ -134,7 +134,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
apiPullRequest := &api.PullRequestPayload{
Index: issue.Index,
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
}
if removed {
@@ -152,7 +152,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
apiIssue := &api.IssuePayload{
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
}
if removed {
@@ -186,7 +186,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
},
},
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
})
} else {
@@ -199,7 +199,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
},
},
Issue: convert.ToAPIIssue(issue),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(issue.Poster, false, false),
})
}
@@ -221,7 +221,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode
apiPullRequest := &api.PullRequestPayload{
Index: issue.Index,
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
}
if isClosed {
@@ -234,7 +234,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode
apiIssue := &api.IssuePayload{
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
}
if isClosed {
@@ -264,7 +264,7 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue) {
Action: api.HookIssueOpened,
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(issue.Poster, false, false),
}); err != nil {
log.Error("PrepareWebhooks: %v", err)
@@ -290,7 +290,7 @@ func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest) {
Action: api.HookIssueOpened,
Index: pull.Issue.Index,
PullRequest: convert.ToAPIPullRequest(pull),
- Repository: pull.Issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(pull.Issue.Repo, mode),
Sender: convert.ToUser(pull.Issue.Poster, false, false),
}); err != nil {
log.Error("PrepareWebhooks: %v", err)
@@ -311,7 +311,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
},
},
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
})
} else {
@@ -324,7 +324,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
},
},
Issue: convert.ToAPIIssue(issue),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
})
}
@@ -361,7 +361,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme
From: oldContent,
},
},
- Repository: c.Issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(c.Issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
IsPull: true,
})
@@ -375,7 +375,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme
From: oldContent,
},
},
- Repository: c.Issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(c.Issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
IsPull: false,
})
@@ -396,7 +396,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode
Action: api.HookIssueCommentCreated,
Issue: convert.ToAPIIssue(issue),
Comment: convert.ToComment(comment),
- Repository: repo.APIFormat(mode),
+ Repository: convert.ToRepo(repo, mode),
Sender: convert.ToUser(doer, false, false),
IsPull: true,
})
@@ -405,7 +405,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode
Action: api.HookIssueCommentCreated,
Issue: convert.ToAPIIssue(issue),
Comment: convert.ToComment(comment),
- Repository: repo.APIFormat(mode),
+ Repository: convert.ToRepo(repo, mode),
Sender: convert.ToUser(doer, false, false),
IsPull: false,
})
@@ -440,7 +440,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models
Action: api.HookIssueCommentDeleted,
Issue: convert.ToAPIIssue(comment.Issue),
Comment: convert.ToComment(comment),
- Repository: comment.Issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(comment.Issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
IsPull: true,
})
@@ -449,7 +449,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models
Action: api.HookIssueCommentDeleted,
Issue: convert.ToAPIIssue(comment.Issue),
Comment: convert.ToComment(comment),
- Repository: comment.Issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(comment.Issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
IsPull: false,
})
@@ -489,7 +489,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode
Action: api.HookIssueLabelUpdated,
Index: issue.Index,
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
- Repository: issue.Repo.APIFormat(models.AccessModeNone),
+ Repository: convert.ToRepo(issue.Repo, models.AccessModeNone),
Sender: convert.ToUser(doer, false, false),
})
} else {
@@ -497,7 +497,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode
Action: api.HookIssueLabelUpdated,
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
})
}
@@ -531,7 +531,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m
Action: hookAction,
Index: issue.Index,
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
})
} else {
@@ -539,7 +539,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m
Action: hookAction,
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
})
}
@@ -562,7 +562,7 @@ func (m *webhookNotifier) NotifyPushCommits(pusher *models.User, repo *models.Re
After: opts.NewCommitID,
CompareURL: setting.AppURL + commits.CompareURL,
Commits: apiCommits,
- Repo: repo.APIFormat(models.AccessModeOwner),
+ Repo: convert.ToRepo(repo, models.AccessModeOwner),
Pusher: apiPusher,
Sender: apiPusher,
}); err != nil {
@@ -597,7 +597,7 @@ func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mod
apiPullRequest := &api.PullRequestPayload{
Index: pr.Issue.Index,
PullRequest: convert.ToAPIPullRequest(pr),
- Repository: pr.Issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(pr.Issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
Action: api.HookIssueClosed,
}
@@ -630,7 +630,7 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *models.User,
},
},
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
- Repository: issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(issue.Repo, mode),
Sender: convert.ToUser(doer, false, false),
})
@@ -669,7 +669,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
Action: api.HookIssueReviewed,
Index: review.Issue.Index,
PullRequest: convert.ToAPIPullRequest(pr),
- Repository: review.Issue.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(review.Issue.Repo, mode),
Sender: convert.ToUser(review.Reviewer, false, false),
Review: &api.ReviewPayload{
Type: string(reviewHookType),
@@ -682,7 +682,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
func (m *webhookNotifier) NotifyCreateRef(pusher *models.User, repo *models.Repository, refType, refFullName string) {
apiPusher := convert.ToUser(pusher, false, false)
- apiRepo := repo.APIFormat(models.AccessModeNone)
+ apiRepo := convert.ToRepo(repo, models.AccessModeNone)
refName := git.RefEndName(refFullName)
gitRepo, err := git.OpenRepository(repo.RepoPath())
@@ -724,7 +724,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *models.User, pr *m
Action: api.HookIssueSynchronized,
Index: pr.Issue.Index,
PullRequest: convert.ToAPIPullRequest(pr),
- Repository: pr.Issue.Repo.APIFormat(models.AccessModeNone),
+ Repository: convert.ToRepo(pr.Issue.Repo, models.AccessModeNone),
Sender: convert.ToUser(doer, false, false),
}); err != nil {
log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err)
@@ -733,7 +733,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *models.User, pr *m
func (m *webhookNotifier) NotifyDeleteRef(pusher *models.User, repo *models.Repository, refType, refFullName string) {
apiPusher := convert.ToUser(pusher, false, false)
- apiRepo := repo.APIFormat(models.AccessModeNone)
+ apiRepo := convert.ToRepo(repo, models.AccessModeNone)
refName := git.RefEndName(refFullName)
if err := webhook_module.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
@@ -757,7 +757,7 @@ func sendReleaseHook(doer *models.User, rel *models.Release, action api.HookRele
if err := webhook_module.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
Action: action,
Release: convert.ToRelease(rel),
- Repository: rel.Repo.APIFormat(mode),
+ Repository: convert.ToRepo(rel.Repo, mode),
Sender: convert.ToUser(rel.Publisher, false, false),
}); err != nil {
log.Error("PrepareWebhooks: %v", err)
@@ -790,7 +790,7 @@ func (m *webhookNotifier) NotifySyncPushCommits(pusher *models.User, repo *model
After: opts.NewCommitID,
CompareURL: setting.AppURL + commits.CompareURL,
Commits: apiCommits,
- Repo: repo.APIFormat(models.AccessModeOwner),
+ Repo: convert.ToRepo(repo, models.AccessModeOwner),
Pusher: apiPusher,
Sender: apiPusher,
}); err != nil {