feat: add visible trash restore for files
All checks were successful
CI / hygiene (push) Successful in 2s
Build and Deploy / build-and-deploy (push) Successful in 34s
CI / test (push) Successful in 19s

This commit is contained in:
Grendgi
2026-06-16 15:48:09 +03:00
parent 3dc5044c99
commit c831d2c7c6
4 changed files with 145 additions and 1 deletions

View File

@@ -240,6 +240,21 @@ func (h *NodeHandler) Move(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, node)
}
func (h *NodeHandler) Restore(w http.ResponseWriter, r *http.Request) {
userID := commonmw.GetUserID(r.Context())
node, err := h.repo.Restore(r.Context(), chi.URLParam(r, "id"), userID, subordinates(r))
if errors.Is(err, repository.ErrNotFound) {
writeError(w, http.StatusNotFound, "file not found")
return
}
if err != nil {
writeInternalError(w, r, err, "failed to restore file")
return
}
h.repo.Audit(r.Context(), userID, "files.node_restore", "files_node", node.ID, "{}")
writeJSON(w, http.StatusOK, node)
}
func (h *NodeHandler) Delete(w http.ResponseWriter, r *http.Request) {
userID := commonmw.GetUserID(r.Context())
id := chi.URLParam(r, "id")
@@ -338,7 +353,16 @@ func (h *NodeHandler) PublicMeta(w http.ResponseWriter, r *http.Request) {
if !ok {
return
}
writeJSON(w, http.StatusOK, node)
response := model.PublicNodeResponse{Node: node}
if node.NodeType == model.NodeTypeFolder {
children, err := h.repo.ListChildrenForPublic(r.Context(), node.ID)
if err != nil {
writeInternalError(w, r, err, "failed to list folder")
return
}
response.Children = children
}
writeJSON(w, http.StatusOK, response)
}
func (h *NodeHandler) PublicDownload(w http.ResponseWriter, r *http.Request) {