Fully deprecate /api/v4/image endpoint when image proxy is disabled (#27595)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1158e6358c
Коммит
f290745496
@@ -37,10 +37,17 @@ func getImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
parsedURL.Host = siteURL.Host
|
||||
}
|
||||
|
||||
// in case image proxy is enabled and we are fetching a remote image (NOT static or served by plugins), pass request to proxy
|
||||
if *c.App.Config().ImageProxySettings.Enable && parsedURL.Host != siteURL.Host {
|
||||
c.App.ImageProxy().GetImage(w, r, parsedURL.String())
|
||||
} else {
|
||||
http.Redirect(w, r, parsedURL.String(), http.StatusFound)
|
||||
if *c.App.Config().ImageProxySettings.Enable {
|
||||
// in case image proxy is enabled and we are fetching a remote image (NOT static or served by plugins), pass request to proxy
|
||||
if parsedURL.Host != siteURL.Host {
|
||||
c.App.ImageProxy().GetImage(w, r, parsedURL.String())
|
||||
} else {
|
||||
// Otherwise we redirect.
|
||||
http.Redirect(w, r, parsedURL.String(), http.StatusFound)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// When proxy disabled this endpoint should fail as we don't support redirecting to external images any longer (MM-54477).
|
||||
c.Err = model.NewAppError("getImage", "api.image.get.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user