mirror of
https://github.com/m1k1o/neko.git
synced 2026-11-03 00:11:48 -06:00
feat(filetransfer): allow file deletion and add user delete config option (#683)
* feat(filetransfer): allow file deletion and add user delete config option * fix(client): make user_delete required boolean in payload * lint. * feat(filetransfer): add confirmation dialog for file deletion. * feat(filetransfer): add delete file confirmation messages in multiple languages * lint. --------- Co-authored-by: Miroslav Šedivý <sedivy.miro@gmail.com>
This commit is contained in:
committed by
GitHub
parent
30d8e1c595
commit
d6a4200b36
@@ -388,6 +388,34 @@ func (h *LegacyHandler) Route(r types.Router) {
|
||||
return err
|
||||
})
|
||||
|
||||
r.Delete("/file", func(w http.ResponseWriter, r *http.Request) error {
|
||||
if h.isBanned(r) {
|
||||
return utils.HttpForbidden("banned ip")
|
||||
}
|
||||
|
||||
s := h.newSession(r)
|
||||
|
||||
// create a new session
|
||||
username := r.URL.Query().Get("usr")
|
||||
password := r.URL.Query().Get("pwd")
|
||||
err := s.create(username, password)
|
||||
if err != nil {
|
||||
return utils.HttpForbidden(err.Error())
|
||||
}
|
||||
defer s.destroy()
|
||||
|
||||
filename := r.URL.Query().Get("filename")
|
||||
|
||||
body, _, err := s.req(http.MethodDelete, "/api/filetransfer?filename="+url.QueryEscape(filename), r.Header, nil)
|
||||
if err != nil {
|
||||
return utils.HttpInternalServerError().WithInternalErr(err)
|
||||
}
|
||||
|
||||
// copy the body to the response writer
|
||||
_, err = io.Copy(w, body)
|
||||
return err
|
||||
})
|
||||
|
||||
r.Get("/health", func(w http.ResponseWriter, r *http.Request) error {
|
||||
_, err := w.Write([]byte("true"))
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user