api use
CI / lint-backend (push) Successful in 1m24s
CI / lint-mobile (push) Failing after 7m28s
CI / test-backend (push) Successful in 1m25s
CI / test-mobile (push) Successful in 9m9s
CI / build-backend (push) Successful in 45s
CI / docker (push) Successful in 33s

This commit is contained in:
venture
2026-09-25 17:34:35 +02:00
parent b869f70922
commit c642763035
41 changed files with 2270 additions and 138 deletions
+52
View File
@@ -0,0 +1,52 @@
package handlers
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/kazier/backend/pkg/api"
)
// SharesList exposes the active user-to-user grants of a resource the caller
// OWNS : GET /files/:id/shares. Non-owner (or unknown resource) → 404
// NOT_FOUND (no enumeration, same scoping as the share outbox ops).
func SharesList(c *gin.Context) {
if Store == nil {
api.Error(c, http.StatusServiceUnavailable, "SERVICE_UNAVAILABLE", "backend not initialized")
return
}
userID := c.GetString(UserIDKey)
id := c.Param("id")
if !deviceIDPattern.MatchString(id) {
api.Error(c, http.StatusNotFound, "NOT_FOUND", "file not found")
return
}
grants, err := Store.ListShares(userID, id)
if err != nil {
writeError(c, err)
return
}
api.OK(c, grants)
}
// LinksList exposes the active public links of a resource the caller OWNS :
// GET /files/:id/links. Same owner-only scoping as SharesList.
func LinksList(c *gin.Context) {
if Store == nil {
api.Error(c, http.StatusServiceUnavailable, "SERVICE_UNAVAILABLE", "backend not initialized")
return
}
userID := c.GetString(UserIDKey)
id := c.Param("id")
if !deviceIDPattern.MatchString(id) {
api.Error(c, http.StatusNotFound, "NOT_FOUND", "file not found")
return
}
links, err := Store.ListLinks(userID, id)
if err != nil {
writeError(c, err)
return
}
api.OK(c, links)
}