From 4e0840969b59fb170ac6f767b804a31e55fbc82d Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Fri, 1 Feb 2019 08:13:51 -0800 Subject: [PATCH] MM-13923 Fixing pulling from incorect cache. (#10216) * Fixing pulling from incorect cache. * Adding caching test. --- api4/system.go | 2 +- api4/system_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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)