tenseleyflow/shithub / bc94561

Browse files

S26: route star API visibility through policy.RepoRef.IsPublic

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
bc9456129425138b2a2caf6f445131a4380900fe
Parents
3d8b283
Tree
4480132

1 changed file

StatusFile+-
M internal/web/handlers/api/stars.go 2 2
internal/web/handlers/api/stars.gomodified
@@ -45,7 +45,7 @@ func (h *Handlers) starPut(w http.ResponseWriter, r *http.Request) {
4545
 		return
4646
 	}
4747
 	auth := middleware.PATAuthFromContext(r.Context())
48
-	if err := social.Star(r.Context(), social.Deps{Pool: h.d.Pool}, auth.UserID, repo.ID, repo.Visibility == reposdb.RepoVisibilityPublic); err != nil {
48
+	if err := social.Star(r.Context(), social.Deps{Pool: h.d.Pool}, auth.UserID, repo.ID, policy.NewRepoRefFromRepo(repo).IsPublic()); err != nil {
4949
 		writeAPIError(w, http.StatusInternalServerError, "star failed")
5050
 		return
5151
 	}
@@ -58,7 +58,7 @@ func (h *Handlers) starDelete(w http.ResponseWriter, r *http.Request) {
5858
 		return
5959
 	}
6060
 	auth := middleware.PATAuthFromContext(r.Context())
61
-	if err := social.Unstar(r.Context(), social.Deps{Pool: h.d.Pool}, auth.UserID, repo.ID, repo.Visibility == reposdb.RepoVisibilityPublic); err != nil {
61
+	if err := social.Unstar(r.Context(), social.Deps{Pool: h.d.Pool}, auth.UserID, repo.ID, policy.NewRepoRefFromRepo(repo).IsPublic()); err != nil {
6262
 		writeAPIError(w, http.StatusInternalServerError, "unstar failed")
6363
 		return
6464
 	}