diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-09-06 02:37:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-05 18:37:47 +0000 |
commit | 540bf9fa6d0d86297c9d575640798b718767bd9f (patch) | |
tree | 4b4a782b71e6f066af6c7807337745dc5ee6899a /routers | |
parent | 084eacb5d42f1ed2520442a4bbc91bb70c9759e1 (diff) | |
download | gitea-540bf9fa6d0d86297c9d575640798b718767bd9f.tar.gz gitea-540bf9fa6d0d86297c9d575640798b718767bd9f.zip |
Move notification interface to services layer (#26915)
Extract from #22266
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/packages/conan/conan.go | 4 | ||||
-rw-r--r-- | routers/api/packages/container/manifest.go | 4 | ||||
-rw-r--r-- | routers/api/packages/debian/debian.go | 4 | ||||
-rw-r--r-- | routers/api/packages/rpm/rpm.go | 4 | ||||
-rw-r--r-- | routers/api/v1/repo/issue.go | 6 | ||||
-rw-r--r-- | routers/api/v1/repo/migrate.go | 4 | ||||
-rw-r--r-- | routers/api/v1/repo/pull.go | 8 | ||||
-rw-r--r-- | routers/api/v1/repo/wiki.go | 8 | ||||
-rw-r--r-- | routers/web/repo/pull.go | 4 | ||||
-rw-r--r-- | routers/web/repo/wiki.go | 8 |
10 files changed, 27 insertions, 27 deletions
diff --git a/routers/api/packages/conan/conan.go b/routers/api/packages/conan/conan.go index d7349a84b2..58e1642442 100644 --- a/routers/api/packages/conan/conan.go +++ b/routers/api/packages/conan/conan.go @@ -18,11 +18,11 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/notification" packages_module "code.gitea.io/gitea/modules/packages" conan_module "code.gitea.io/gitea/modules/packages/conan" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers/api/packages/helper" + notify_service "code.gitea.io/gitea/services/notify" packages_service "code.gitea.io/gitea/services/packages" ) @@ -663,7 +663,7 @@ func deleteRecipeOrPackage(apictx *context.Context, rref *conan_module.RecipeRef } if versionDeleted { - notification.NotifyPackageDelete(apictx, apictx.Doer, pd) + notify_service.PackageDelete(apictx, apictx.Doer, pd) } return nil diff --git a/routers/api/packages/container/manifest.go b/routers/api/packages/container/manifest.go index 6678ed20bc..4a79a58f51 100644 --- a/routers/api/packages/container/manifest.go +++ b/routers/api/packages/container/manifest.go @@ -17,10 +17,10 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/notification" packages_module "code.gitea.io/gitea/modules/packages" container_module "code.gitea.io/gitea/modules/packages/container" "code.gitea.io/gitea/modules/util" + notify_service "code.gitea.io/gitea/services/notify" packages_service "code.gitea.io/gitea/services/packages" digest "github.com/opencontainers/go-digest" @@ -306,7 +306,7 @@ func notifyPackageCreate(ctx context.Context, doer *user_model.User, pv *package return err } - notification.NotifyPackageCreate(ctx, doer, pd) + notify_service.PackageCreate(ctx, doer, pd) return nil } diff --git a/routers/api/packages/debian/debian.go b/routers/api/packages/debian/debian.go index a6da1a11a8..04ca2ed977 100644 --- a/routers/api/packages/debian/debian.go +++ b/routers/api/packages/debian/debian.go @@ -14,11 +14,11 @@ import ( "code.gitea.io/gitea/models/db" packages_model "code.gitea.io/gitea/models/packages" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/notification" packages_module "code.gitea.io/gitea/modules/packages" debian_module "code.gitea.io/gitea/modules/packages/debian" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers/api/packages/helper" + notify_service "code.gitea.io/gitea/services/notify" packages_service "code.gitea.io/gitea/services/packages" debian_service "code.gitea.io/gitea/services/packages/debian" ) @@ -296,7 +296,7 @@ func DeletePackageFile(ctx *context.Context) { } if pd != nil { - notification.NotifyPackageDelete(ctx, ctx.Doer, pd) + notify_service.PackageDelete(ctx, ctx.Doer, pd) } if err := debian_service.BuildSpecificRepositoryFiles(ctx, ctx.Package.Owner.ID, distribution, component, architecture); err != nil { diff --git a/routers/api/packages/rpm/rpm.go b/routers/api/packages/rpm/rpm.go index 930b20208a..1e462bb908 100644 --- a/routers/api/packages/rpm/rpm.go +++ b/routers/api/packages/rpm/rpm.go @@ -15,12 +15,12 @@ import ( packages_model "code.gitea.io/gitea/models/packages" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/json" - "code.gitea.io/gitea/modules/notification" packages_module "code.gitea.io/gitea/modules/packages" rpm_module "code.gitea.io/gitea/modules/packages/rpm" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers/api/packages/helper" + notify_service "code.gitea.io/gitea/services/notify" packages_service "code.gitea.io/gitea/services/packages" rpm_service "code.gitea.io/gitea/services/packages/rpm" ) @@ -247,7 +247,7 @@ func DeletePackageFile(webctx *context.Context) { } if pd != nil { - notification.NotifyPackageDelete(webctx, webctx.Doer, pd) + notify_service.PackageDelete(webctx, webctx.Doer, pd) } if err := rpm_service.BuildRepositoryFiles(webctx, webctx.Package.Owner.ID); err != nil { diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index a08fdf5940..2fad55df3d 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -20,7 +20,6 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" issue_indexer "code.gitea.io/gitea/modules/indexer/issues" - "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" @@ -29,6 +28,7 @@ import ( "code.gitea.io/gitea/routers/api/v1/utils" "code.gitea.io/gitea/services/convert" issue_service "code.gitea.io/gitea/services/issue" + notify_service "code.gitea.io/gitea/services/notify" ) // SearchIssues searches for issues across the repositories that the user has access to @@ -859,11 +859,11 @@ func EditIssue(ctx *context.APIContext) { } if titleChanged { - notification.NotifyIssueChangeTitle(ctx, ctx.Doer, issue, oldTitle) + notify_service.IssueChangeTitle(ctx, ctx.Doer, issue, oldTitle) } if statusChangeComment != nil { - notification.NotifyIssueChangeStatus(ctx, ctx.Doer, "", issue, statusChangeComment, issue.IsClosed) + notify_service.IssueChangeStatus(ctx, ctx.Doer, "", issue, statusChangeComment, issue.IsClosed) } // Refetch from database to assign some automatic values diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go index 84327de5fb..dfc9004620 100644 --- a/routers/api/v1/repo/migrate.go +++ b/routers/api/v1/repo/migrate.go @@ -22,7 +22,6 @@ import ( "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" base "code.gitea.io/gitea/modules/migration" - "code.gitea.io/gitea/modules/notification" repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" @@ -31,6 +30,7 @@ import ( "code.gitea.io/gitea/services/convert" "code.gitea.io/gitea/services/forms" "code.gitea.io/gitea/services/migrations" + notify_service "code.gitea.io/gitea/services/notify" ) // Migrate migrate remote git repository to gitea @@ -195,7 +195,7 @@ func Migrate(ctx *context.APIContext) { } if err == nil { - notification.NotifyMigrateRepository(ctx, ctx.Doer, repoOwner, repo) + notify_service.MigrateRepository(ctx, ctx.Doer, repoOwner, repo) return } diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 58f2fc69ce..f0b958c4cd 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -24,7 +24,6 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" @@ -36,6 +35,7 @@ import ( "code.gitea.io/gitea/services/forms" "code.gitea.io/gitea/services/gitdiff" issue_service "code.gitea.io/gitea/services/issue" + notify_service "code.gitea.io/gitea/services/notify" pull_service "code.gitea.io/gitea/services/pull" repo_service "code.gitea.io/gitea/services/repository" ) @@ -594,11 +594,11 @@ func EditPullRequest(ctx *context.APIContext) { } if titleChanged { - notification.NotifyIssueChangeTitle(ctx, ctx.Doer, issue, oldTitle) + notify_service.IssueChangeTitle(ctx, ctx.Doer, issue, oldTitle) } if statusChangeComment != nil { - notification.NotifyIssueChangeStatus(ctx, ctx.Doer, "", issue, statusChangeComment, issue.IsClosed) + notify_service.IssueChangeStatus(ctx, ctx.Doer, "", issue, statusChangeComment, issue.IsClosed) } // change pull target branch @@ -622,7 +622,7 @@ func EditPullRequest(ctx *context.APIContext) { } return } - notification.NotifyPullRequestChangeTargetBranch(ctx, ctx.Doer, pr, form.Base) + notify_service.PullRequestChangeTargetBranch(ctx, ctx.Doer, pr, form.Base) } // update allow edits diff --git a/routers/api/v1/repo/wiki.go b/routers/api/v1/repo/wiki.go index 7f3a7d0674..1fd1b91936 100644 --- a/routers/api/v1/repo/wiki.go +++ b/routers/api/v1/repo/wiki.go @@ -12,12 +12,12 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" - "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/convert" + notify_service "code.gitea.io/gitea/services/notify" wiki_service "code.gitea.io/gitea/services/wiki" ) @@ -85,7 +85,7 @@ func NewWikiPage(ctx *context.APIContext) { wikiPage := getWikiPage(ctx, wikiName) if !ctx.Written() { - notification.NotifyNewWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName), form.Message) + notify_service.NewWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName), form.Message) ctx.JSON(http.StatusCreated, wikiPage) } } @@ -153,7 +153,7 @@ func EditWikiPage(ctx *context.APIContext) { wikiPage := getWikiPage(ctx, newWikiName) if !ctx.Written() { - notification.NotifyEditWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(newWikiName), form.Message) + notify_service.EditWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(newWikiName), form.Message) ctx.JSON(http.StatusOK, wikiPage) } } @@ -242,7 +242,7 @@ func DeleteWikiPage(ctx *context.APIContext) { return } - notification.NotifyDeleteWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName)) + notify_service.DeleteWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName)) ctx.Status(http.StatusNoContent) } diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index e697a0d5b6..0de3ace792 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -31,7 +31,6 @@ import ( "code.gitea.io/gitea/modules/git" issue_template "code.gitea.io/gitea/modules/issue/template" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/upload" @@ -42,6 +41,7 @@ import ( "code.gitea.io/gitea/services/automerge" "code.gitea.io/gitea/services/forms" "code.gitea.io/gitea/services/gitdiff" + notify_service "code.gitea.io/gitea/services/notify" pull_service "code.gitea.io/gitea/services/pull" repo_service "code.gitea.io/gitea/services/repository" @@ -1672,7 +1672,7 @@ func UpdatePullRequestTarget(ctx *context.Context) { } return } - notification.NotifyPullRequestChangeTargetBranch(ctx, ctx.Doer, pr, targetBranch) + notify_service.PullRequestChangeTargetBranch(ctx, ctx.Doer, pr, targetBranch) ctx.JSON(http.StatusOK, map[string]any{ "base_branch": pr.BaseBranch, diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go index 4de24e2a38..c9cec0313d 100644 --- a/routers/web/repo/wiki.go +++ b/routers/web/repo/wiki.go @@ -23,13 +23,13 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" - "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/routers/common" "code.gitea.io/gitea/services/forms" + notify_service "code.gitea.io/gitea/services/notify" wiki_service "code.gitea.io/gitea/services/wiki" ) @@ -727,7 +727,7 @@ func NewWikiPost(ctx *context.Context) { return } - notification.NotifyNewWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName), form.Message) + notify_service.NewWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName), form.Message) ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + wiki_service.WebPathToURLPath(wikiName)) } @@ -771,7 +771,7 @@ func EditWikiPost(ctx *context.Context) { return } - notification.NotifyEditWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(newWikiName), form.Message) + notify_service.EditWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(newWikiName), form.Message) ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + wiki_service.WebPathToURLPath(newWikiName)) } @@ -788,7 +788,7 @@ func DeleteWikiPagePost(ctx *context.Context) { return } - notification.NotifyDeleteWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName)) + notify_service.DeleteWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName)) ctx.JSONRedirect(ctx.Repo.RepoLink + "/wiki/") } |