mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
upload drop to config.
This commit is contained in:
parent
b40c0778c8
commit
3dbcc41795
@ -16,6 +16,10 @@ import (
|
||||
const maxUploadSize = 32 << 20
|
||||
|
||||
func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) error {
|
||||
if !h.desktop.IsUploadDropEnabled() {
|
||||
return utils.HttpBadRequest("upload drop is disabled")
|
||||
}
|
||||
|
||||
err := r.ParseMultipartForm(maxUploadSize)
|
||||
if err != nil {
|
||||
return utils.HttpBadRequest("failed to parse multipart form").WithInternalErr(err)
|
||||
|
@ -20,6 +20,7 @@ type Desktop struct {
|
||||
InputSocket string
|
||||
|
||||
Unminimize bool
|
||||
UploadDrop bool
|
||||
FileChooserDialog bool
|
||||
}
|
||||
|
||||
@ -44,6 +45,11 @@ func (Desktop) Init(cmd *cobra.Command) error {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().Bool("desktop.upload_drop", true, "whether drop upload is enabled")
|
||||
if err := viper.BindPFlag("desktop.upload_drop", cmd.PersistentFlags().Lookup("desktop.upload_drop")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().Bool("desktop.file_chooser_dialog", false, "whether to handle file chooser dialog externally")
|
||||
if err := viper.BindPFlag("desktop.file_chooser_dialog", cmd.PersistentFlags().Lookup("desktop.file_chooser_dialog")); err != nil {
|
||||
return err
|
||||
@ -80,5 +86,6 @@ func (s *Desktop) Set() {
|
||||
s.UseInputDriver = viper.GetBool("desktop.input.enabled")
|
||||
s.InputSocket = viper.GetString("desktop.input.socket")
|
||||
s.Unminimize = viper.GetBool("desktop.unminimize")
|
||||
s.UploadDrop = viper.GetBool("desktop.upload_drop")
|
||||
s.FileChooserDialog = viper.GetBool("desktop.file_chooser_dialog")
|
||||
}
|
||||
|
@ -62,3 +62,7 @@ func (manager *DesktopManagerCtx) DropFiles(x int, y int, files []string) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (manager *DesktopManagerCtx) IsUploadDropEnabled() bool {
|
||||
return manager.config.UploadDrop
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ type DesktopManager interface {
|
||||
|
||||
// drop
|
||||
DropFiles(x int, y int, files []string) bool
|
||||
IsUploadDropEnabled() bool
|
||||
|
||||
// filechooser
|
||||
HandleFileChooserDialog(uri string) error
|
||||
|
Loading…
Reference in New Issue
Block a user