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) {
45
 		return
45
 		return
46
 	}
46
 	}
47
 	auth := middleware.PATAuthFromContext(r.Context())
47
 	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 {
49
 		writeAPIError(w, http.StatusInternalServerError, "star failed")
49
 		writeAPIError(w, http.StatusInternalServerError, "star failed")
50
 		return
50
 		return
51
 	}
51
 	}
@@ -58,7 +58,7 @@ func (h *Handlers) starDelete(w http.ResponseWriter, r *http.Request) {
58
 		return
58
 		return
59
 	}
59
 	}
60
 	auth := middleware.PATAuthFromContext(r.Context())
60
 	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 {
62
 		writeAPIError(w, http.StatusInternalServerError, "unstar failed")
62
 		writeAPIError(w, http.StatusInternalServerError, "unstar failed")
63
 		return
63
 		return
64
 	}
64
 	}