1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Move notification interface to services layer (#26915)

Extract from #22266
This commit is contained in:
Lunny Xiao
2023-09-06 02:37:47 +08:00
committed by GitHub
parent 084eacb5d4
commit 540bf9fa6d
51 changed files with 972 additions and 969 deletions

View File

@@ -17,11 +17,11 @@ import (
"code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
notify_service "code.gitea.io/gitea/services/notify"
)
func createTag(ctx context.Context, gitRepo *git.Repository, rel *repo_model.Release, msg string) (bool, error) {
@@ -81,14 +81,14 @@ func createTag(ctx context.Context, gitRepo *git.Repository, rel *repo_model.Rel
commits.CompareURL = rel.Repo.ComposeCompareURL(git.EmptySHA, commit.ID.String())
refFullName := git.RefNameFromTag(rel.TagName)
notification.NotifyPushCommits(
notify_service.PushCommits(
ctx, rel.Publisher, rel.Repo,
&repository.PushUpdateOptions{
RefFullName: refFullName,
OldCommitID: git.EmptySHA,
NewCommitID: commit.ID.String(),
}, commits)
notification.NotifyCreateRef(ctx, rel.Publisher, rel.Repo, refFullName, commit.ID.String())
notify_service.CreateRef(ctx, rel.Publisher, rel.Repo, refFullName, commit.ID.String())
rel.CreatedUnix = timeutil.TimeStampNow()
}
commit, err := gitRepo.GetTagCommit(rel.TagName)
@@ -139,7 +139,7 @@ func CreateRelease(gitRepo *git.Repository, rel *repo_model.Release, attachmentU
}
if !rel.IsDraft {
notification.NotifyNewRelease(gitRepo.Ctx, rel)
notify_service.NewRelease(gitRepo.Ctx, rel)
}
return nil
@@ -279,12 +279,12 @@ func UpdateRelease(doer *user_model.User, gitRepo *git.Repository, rel *repo_mod
}
if !isCreated {
notification.NotifyUpdateRelease(gitRepo.Ctx, doer, rel)
notify_service.UpdateRelease(gitRepo.Ctx, doer, rel)
return nil
}
if !rel.IsDraft {
notification.NotifyNewRelease(gitRepo.Ctx, rel)
notify_service.NewRelease(gitRepo.Ctx, rel)
}
return nil
@@ -325,14 +325,14 @@ func DeleteReleaseByID(ctx context.Context, id int64, doer *user_model.User, del
}
refName := git.RefNameFromTag(rel.TagName)
notification.NotifyPushCommits(
notify_service.PushCommits(
ctx, doer, repo,
&repository.PushUpdateOptions{
RefFullName: refName,
OldCommitID: rel.Sha1,
NewCommitID: git.EmptySHA,
}, repository.NewPushCommits())
notification.NotifyDeleteRef(ctx, doer, repo, refName)
notify_service.DeleteRef(ctx, doer, repo, refName)
if err := repo_model.DeleteReleaseByID(ctx, id); err != nil {
return fmt.Errorf("DeleteReleaseByID: %w", err)
@@ -361,7 +361,7 @@ func DeleteReleaseByID(ctx context.Context, id int64, doer *user_model.User, del
}
}
notification.NotifyDeleteRelease(ctx, doer, rel)
notify_service.DeleteRelease(ctx, doer, rel)
return nil
}