mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
texttmpl "text/template"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/emoji"
|
||||
@@ -176,7 +177,7 @@ func SendRegisterNotifyMail(u *user_model.User) {
|
||||
}
|
||||
|
||||
// SendCollaboratorMail sends mail notification to new collaborator.
|
||||
func SendCollaboratorMail(u, doer *user_model.User, repo *models.Repository) {
|
||||
func SendCollaboratorMail(u, doer *user_model.User, repo *repo_model.Repository) {
|
||||
if setting.MailService == nil {
|
||||
// No mail service configured
|
||||
return
|
||||
|
@@ -139,7 +139,7 @@ func mailIssueCommentBatch(ctx *mailCommentContext, users []*user_model.User, vi
|
||||
visited[user.ID] = true
|
||||
|
||||
// test if this user is allowed to see the issue/pull
|
||||
if !ctx.Issue.Repo.CheckUnitUser(user, checkUnit) {
|
||||
if !models.CheckRepoUnitUser(ctx.Issue.Repo, user, checkUnit) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/templates"
|
||||
@@ -16,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
// SendRepoTransferNotifyMail triggers a notification e-mail when a pending repository transfer was created
|
||||
func SendRepoTransferNotifyMail(doer, newOwner *user_model.User, repo *models.Repository) error {
|
||||
func SendRepoTransferNotifyMail(doer, newOwner *user_model.User, repo *repo_model.Repository) error {
|
||||
if setting.MailService == nil {
|
||||
// No mail service configured
|
||||
return nil
|
||||
@@ -46,7 +47,7 @@ func SendRepoTransferNotifyMail(doer, newOwner *user_model.User, repo *models.Re
|
||||
}
|
||||
|
||||
// sendRepoTransferNotifyMail triggers a notification e-mail when a pending repository transfer was created for each language
|
||||
func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *user_model.User, emails []string, repo *models.Repository) error {
|
||||
func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *user_model.User, emails []string, repo *repo_model.Repository) error {
|
||||
var (
|
||||
locale = translation.NewLocale(lang)
|
||||
content bytes.Buffer
|
||||
|
@@ -11,6 +11,7 @@ import (
|
||||
texttmpl "text/template"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
@@ -41,7 +42,7 @@ const bodyTpl = `
|
||||
</html>
|
||||
`
|
||||
|
||||
func prepareMailerTest(t *testing.T) (doer *user_model.User, repo *models.Repository, issue *models.Issue, comment *models.Comment) {
|
||||
func prepareMailerTest(t *testing.T) (doer *user_model.User, repo *repo_model.Repository, issue *models.Issue, comment *models.Comment) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
var mailService = setting.Mailer{
|
||||
From: "test@gitea.com",
|
||||
@@ -51,7 +52,7 @@ func prepareMailerTest(t *testing.T) (doer *user_model.User, repo *models.Reposi
|
||||
setting.Domain = "localhost"
|
||||
|
||||
doer = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
|
||||
repo = unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1, Owner: doer}).(*models.Repository)
|
||||
repo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1, Owner: doer}).(*repo_model.Repository)
|
||||
issue = unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 1, Repo: repo, Poster: doer}).(*models.Issue)
|
||||
assert.NoError(t, issue.LoadRepo())
|
||||
comment = unittest.AssertExistsAndLoadBean(t, &models.Comment{ID: 2, Issue: issue}).(*models.Comment)
|
||||
|
Reference in New Issue
Block a user