Skip to content

Commit eb07bec

Browse files
committed
Deduplicate stars middlewares
oops.
1 parent 59b9147 commit eb07bec

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

routers/web/repo/repo.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,7 @@ func Action(ctx *context.Context) {
376376
case "watch", "unwatch":
377377
ctx.Data["IsWatchingRepo"] = repo_model.IsWatching(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
378378
case "star", "unstar":
379-
if setting.Repository.DisableStars {
380-
ctx.Data["IsStaringRepo"] = false
381-
} else {
382-
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
383-
}
379+
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
384380
}
385381

386382
// see the `hx-trigger="refreshUserCards ..."` comments in tmpl

routers/web/web.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -851,12 +851,6 @@ func registerRoutes(m *web.Router) {
851851
}
852852
}
853853

854-
reqStarsEnabled := func(ctx *context.Context) {
855-
if setting.Repository.DisableStars {
856-
ctx.Error(http.StatusForbidden, "stars are disabled")
857-
}
858-
}
859-
860854
individualPermsChecker := func(ctx *context.Context) {
861855
// org permissions have been checked in context.OrgAssignment(), but individual permissions haven't been checked.
862856
if ctx.ContextUser.IsIndividual() {
@@ -1609,7 +1603,7 @@ func registerRoutes(m *web.Router) {
16091603
m.Get("/stars", starsEnabled, repo.Stars)
16101604
m.Get("/watchers", repo.Watchers)
16111605
m.Get("/search", reqUnitCodeReader, repo.Search)
1612-
m.Post("/action/{action:star|unstar}", reqSignIn, reqStarsEnabled, repo.Action)
1606+
m.Post("/action/{action:star|unstar}", reqSignIn, starsEnabled, repo.Action)
16131607
m.Post("/action/{action:watch|unwatch}", reqSignIn, repo.Action)
16141608
m.Post("/action/{action:accept_transfer|reject_transfer}", reqSignIn, repo.Action)
16151609
}, optSignIn, context.RepoAssignment)

0 commit comments

Comments
 (0)