Track file upload activity
This commit is contained in:
parent
c18e844689
commit
e3ab241d7f
|
@ -3,6 +3,7 @@ package router
|
|||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"github.com/pterodactyl/wings/internal/models"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
|
@ -600,6 +601,11 @@ func postServerUploadFiles(c *gin.Context) {
|
|||
if err := handleFileUpload(p, s, header); err != nil {
|
||||
NewServerError(err, s).Abort(c)
|
||||
return
|
||||
} else {
|
||||
s.SaveActivity(s.NewRequestActivity(token.UserUuid, c.Request.RemoteAddr), server.ActivityFileUploaded, models.ActivityMeta{
|
||||
"file": header.Filename,
|
||||
"directory": filepath.Clean(directory),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -617,6 +623,5 @@ func handleFileUpload(p string, s *server.Server, header *multipart.FileHeader)
|
|||
if err := s.Filesystem().Writefile(p, file); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ type UploadPayload struct {
|
|||
jwt.Payload
|
||||
|
||||
ServerUuid string `json:"server_uuid"`
|
||||
UserUuid string `json:"user_uuid"`
|
||||
UniqueId string `json:"unique_id"`
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ const (
|
|||
ActivitySftpCreateDirectory = models.Event("server:sftp.create-directory")
|
||||
ActivitySftpRename = models.Event("server:sftp.rename")
|
||||
ActivitySftpDelete = models.Event("server:sftp.delete")
|
||||
ActivityFileUploaded = models.Event("server:file.uploaded")
|
||||
)
|
||||
|
||||
// RequestActivity is a wrapper around a LoggedEvent that is able to track additional request
|
||||
|
|
Loading…
Reference in New Issue
Block a user