diff --git a/api4/system.go b/api4/system.go index 923208fea0..e4437d66c1 100644 --- a/api4/system.go +++ b/api4/system.go @@ -489,7 +489,7 @@ func getRedirectLocation(c *Context, w http.ResponseWriter, r *http.Request) { return } - if location, ok := openGraphDataCache.Get(url); ok { + if location, ok := redirectLocationDataCache.Get(url); ok { m["location"] = location.(string) w.Write([]byte(model.MapToJson(m))) return diff --git a/api4/system_test.go b/api4/system_test.go index c6641b404d..e0e2bfaca4 100644 --- a/api4/system_test.go +++ b/api4/system_test.go @@ -771,6 +771,11 @@ func TestRedirectLocation(t *testing.T) { CheckNoError(t, resp) assert.Equal(t, expected, actual) + // Check cached value + actual, resp = th.SystemAdminClient.GetRedirectLocation(mockBitlyLink, "") + CheckNoError(t, resp) + assert.Equal(t, expected, actual) + *th.App.Config().ServiceSettings.EnableLinkPreviews = false actual, resp = th.SystemAdminClient.GetRedirectLocation("https://mattermost.com/", "") CheckNoError(t, resp)