MM-54275 : Add Giphy production key to LDFlags (#24397)

Этот коммит содержится в:
M-ZubairAhmed
2023-08-31 20:29:04 +05:30
коммит произвёл GitHub
родитель 2c6179a0a6
Коммит 66e5d5fffa
4 изменённых файлов: 33 добавлений и 9 удалений

Просмотреть файл

@@ -81,7 +81,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
props["EnableGifPicker"] = strconv.FormatBool(*c.ServiceSettings.EnableGifPicker)
props["GfycatApiKey"] = *c.ServiceSettings.GfycatAPIKey
props["GfycatApiSecret"] = *c.ServiceSettings.GfycatAPISecret
props["GiphySdkKey"] = *c.ServiceSettings.GiphySdkKey
props["GiphySdkKey"] = getGiphySdkKey(c.ServiceSettings)
props["MaxFileSize"] = strconv.FormatInt(*c.FileSettings.MaxFileSize, 10)
props["MaxNotificationsPerChannel"] = strconv.FormatInt(*c.TeamSettings.MaxNotificationsPerChannel, 10)
@@ -378,3 +378,17 @@ func GenerateLimitedClientConfig(c *model.Config, telemetryID string, license *m
return props
}
func getGiphySdkKey(ss model.ServiceSettings) string {
if model.GetServiceEnvironment() == model.ServiceEnvironmentProduction {
if *ss.GiphySdkKey != "" {
return *ss.GiphySdkKey
}
return model.MattermostGiphySdkKey
} else if model.GetServiceEnvironment() == model.ServiceEnvironmentDev || model.GetServiceEnvironment() == model.ServiceEnvironmentTest {
return model.ServiceSettingsDefaultGiphySdkKeyTest
}
return ""
}

Просмотреть файл

@@ -293,6 +293,19 @@ func TestGetClientConfig(t *testing.T) {
"EnableJoinLeaveMessageByDefault": "false",
},
},
{
"test key for GiphySdkKey",
&model.Config{
ServiceSettings: model.ServiceSettings{
GiphySdkKey: model.NewString(""),
},
},
"",
nil,
map[string]string{
"GiphySdkKey": model.ServiceSettingsDefaultGiphySdkKeyTest,
},
},
}
for _, testCase := range testCases {