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) }