when receiving file attachments for shared channels, ensure attachments are enabled and file size does not exceed maximum configured for receiving server. (#27018)
Этот коммит содержится в:
@@ -8,6 +8,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
@@ -172,6 +173,20 @@ func (scs *Service) onReceiveUploadCreate(msg model.RemoteClusterMsg, rc *model.
|
|||||||
return fmt.Errorf("could not validate upload session for remote: %w", err)
|
return fmt.Errorf("could not validate upload session for remote: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure file attachments are enabled
|
||||||
|
if scs.server.Config().FileSettings.EnableFileAttachments == nil || !*scs.server.Config().FileSettings.EnableFileAttachments {
|
||||||
|
return model.NewAppError("ReceiveUploadCreate",
|
||||||
|
"api.file.attachments.disabled.app_error",
|
||||||
|
nil, "", http.StatusNotImplemented)
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure the file size requested does not exceed local server config - MM server's regular
|
||||||
|
// upload code will ensure the actual bytes sent are within the upload session limit.
|
||||||
|
if scs.server.Config().FileSettings.MaxFileSize == nil || us.FileSize > *scs.server.Config().FileSettings.MaxFileSize {
|
||||||
|
return model.NewAppError("createUpload", "api.upload.create.upload_too_large.app_error",
|
||||||
|
map[string]any{"channelId": us.ChannelId}, "", http.StatusRequestEntityTooLarge)
|
||||||
|
}
|
||||||
|
|
||||||
us.RemoteId = rc.RemoteId // don't let remotes try to impersonate each other
|
us.RemoteId = rc.RemoteId // don't let remotes try to impersonate each other
|
||||||
|
|
||||||
// create upload session.
|
// create upload session.
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user