MM-27493 Shared channels (MVP) (#17301)
Remote Cluster Service - provides ability for multiple Mattermost cluster instances to create a trusted connection with each other and exchange messages - trusted connections are managed via slash commands (for now) - facilitates features requiring inter-cluster communication, such as Shared Channels Shared Channels Service - provides ability to shared channels between one or more Mattermost cluster instances (using trusted connection) - sharing/unsharing of channels is managed via slash commands (for now)
Этот коммит содержится в:
@@ -33,6 +33,10 @@ func createUpload(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// these are not supported for client uploads; shared channels only.
|
||||
us.RemoteId = ""
|
||||
us.ReqFileId = ""
|
||||
|
||||
auditRec := c.MakeAuditRecord("createUpload", audit.Fail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
auditRec.AddMeta("upload", us)
|
||||
@@ -119,33 +123,7 @@ func uploadData(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
boundary, parseErr := parseMultipartRequestHeader(r)
|
||||
if parseErr != nil && !errors.Is(parseErr, http.ErrNotMultipart) {
|
||||
c.Err = model.NewAppError("uploadData", "api.upload.upload_data.invalid_content_type",
|
||||
nil, parseErr.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
var rd io.Reader
|
||||
if boundary != "" {
|
||||
mr := multipart.NewReader(r.Body, boundary)
|
||||
p, partErr := mr.NextPart()
|
||||
if partErr != nil {
|
||||
c.Err = model.NewAppError("uploadData", "api.upload.upload_data.multipart_error",
|
||||
nil, partErr.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
rd = p
|
||||
} else {
|
||||
if r.ContentLength > (us.FileSize - us.FileOffset) {
|
||||
c.Err = model.NewAppError("uploadData", "api.upload.upload_data.invalid_content_length",
|
||||
nil, "", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
rd = r.Body
|
||||
}
|
||||
|
||||
info, err := c.App.UploadData(us, rd)
|
||||
info, err := doUploadData(c, us, r)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -160,3 +138,30 @@ func uploadData(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Write([]byte(info.ToJson()))
|
||||
}
|
||||
|
||||
func doUploadData(c *Context, us *model.UploadSession, r *http.Request) (*model.FileInfo, *model.AppError) {
|
||||
boundary, parseErr := parseMultipartRequestHeader(r)
|
||||
if parseErr != nil && !errors.Is(parseErr, http.ErrNotMultipart) {
|
||||
return nil, model.NewAppError("uploadData", "api.upload.upload_data.invalid_content_type",
|
||||
nil, parseErr.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
var rd io.Reader
|
||||
if boundary != "" {
|
||||
mr := multipart.NewReader(r.Body, boundary)
|
||||
p, partErr := mr.NextPart()
|
||||
if partErr != nil {
|
||||
return nil, model.NewAppError("uploadData", "api.upload.upload_data.multipart_error",
|
||||
nil, partErr.Error(), http.StatusBadRequest)
|
||||
}
|
||||
rd = p
|
||||
} else {
|
||||
if r.ContentLength > (us.FileSize - us.FileOffset) {
|
||||
return nil, model.NewAppError("uploadData", "api.upload.upload_data.invalid_content_length",
|
||||
nil, "", http.StatusBadRequest)
|
||||
}
|
||||
rd = r.Body
|
||||
}
|
||||
|
||||
return c.App.UploadData(us, rd)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user