Return "null" if MaxFileSizeBytes is 0

This commit is contained in:
Till Faelligen 2022-05-02 08:20:36 +02:00
parent bfa344e831
commit eb7e81ca4f

View file

@ -35,7 +35,7 @@ import (
// configResponse is the response to GET /_matrix/media/r0/config
// https://matrix.org/docs/spec/client_server/latest#get-matrix-media-r0-config
type configResponse struct {
UploadSize config.FileSizeBytes `json:"m.upload.size"`
UploadSize *config.FileSizeBytes `json:"m.upload.size"`
}
// Setup registers the media API HTTP handlers
@ -73,9 +73,13 @@ func Setup(
if r := rateLimits.Limit(req); r != nil {
return *r
}
respondSize := cfg.MaxFileSizeBytes
if *cfg.MaxFileSizeBytes == 0 {
respondSize = nil
}
return util.JSONResponse{
Code: http.StatusOK,
JSON: configResponse{UploadSize: *cfg.MaxFileSizeBytes},
JSON: configResponse{UploadSize: respondSize},
}
})