Report a problem (#30444)
* Add report a problem type and allow logs config * Improve device type logic * Add tests and minor fixes * Add texts * Fix tests by avoiding circular dependencies * Fix test * Fix useexternallink updating mailtos, and changing the content of query parameters * Fix texts * Fix e2e test * Fix tsc --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
29f7c895b8
Коммит
71334c6d8b
@@ -294,7 +294,10 @@ func GenerateLimitedClientConfig(c *model.Config, telemetryID string, license *m
|
||||
props["PrivacyPolicyLink"] = *c.SupportSettings.PrivacyPolicyLink
|
||||
props["AboutLink"] = *c.SupportSettings.AboutLink
|
||||
props["HelpLink"] = *c.SupportSettings.HelpLink
|
||||
props["ReportAProblemType"] = *c.SupportSettings.ReportAProblemType
|
||||
props["ReportAProblemLink"] = *c.SupportSettings.ReportAProblemLink
|
||||
props["ReportAProblemMail"] = *c.SupportSettings.ReportAProblemMail
|
||||
props["AllowDownloadLogs"] = strconv.FormatBool(*c.SupportSettings.AllowDownloadLogs)
|
||||
props["ForgotPasswordLink"] = *c.SupportSettings.ForgotPasswordLink
|
||||
props["SupportEmail"] = *c.SupportSettings.SupportEmail
|
||||
props["EnableAskCommunityLink"] = strconv.FormatBool(*c.SupportSettings.EnableAskCommunityLink)
|
||||
|
||||
@@ -319,6 +319,25 @@ func TestGetClientConfig(t *testing.T) {
|
||||
"GiphySdkKey": model.ServiceSettingsDefaultGiphySdkKeyTest,
|
||||
},
|
||||
},
|
||||
{
|
||||
"report a problem values",
|
||||
&model.Config{
|
||||
SupportSettings: model.SupportSettings{
|
||||
ReportAProblemType: model.NewPointer("type"),
|
||||
ReportAProblemLink: model.NewPointer("http://example.com"),
|
||||
ReportAProblemMail: model.NewPointer("mail"),
|
||||
AllowDownloadLogs: model.NewPointer(true),
|
||||
},
|
||||
},
|
||||
"",
|
||||
nil,
|
||||
map[string]string{
|
||||
"ReportAProblemType": "type",
|
||||
"ReportAProblemLink": "http://example.com",
|
||||
"ReportAProblemMail": "mail",
|
||||
"AllowDownloadLogs": "true",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
@@ -9308,6 +9308,22 @@
|
||||
"id": "model.config.is_valid.read_timeout.app_error",
|
||||
"translation": "Invalid value for read timeout."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.report_a_problem_link.invalid.app_error",
|
||||
"translation": "Invalid report a problem link. Must be a valid URL and start with http:// or https://."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.report_a_problem_link.missing.app_error",
|
||||
"translation": "Report a problem link is required."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.report_a_problem_mail.invalid.app_error",
|
||||
"translation": "Invalid report a problem mail. Must be a valid email address."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.report_a_problem_mail.missing.app_error",
|
||||
"translation": "Report a problem mail is required."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.restrict_direct_message.app_error",
|
||||
"translation": "Invalid direct message restriction. Must be 'any', or 'team'."
|
||||
|
||||
@@ -746,6 +746,8 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"custom_terms_of_service_enabled": *cfg.SupportSettings.CustomTermsOfServiceEnabled,
|
||||
"custom_terms_of_service_re_acceptance_period": *cfg.SupportSettings.CustomTermsOfServiceReAcceptancePeriod,
|
||||
"enable_ask_community_link": *cfg.SupportSettings.EnableAskCommunityLink,
|
||||
"report_a_problem_type": *cfg.SupportSettings.ReportAProblemType,
|
||||
"allow_download_logs": *cfg.SupportSettings.AllowDownloadLogs,
|
||||
}
|
||||
|
||||
configs[TrackConfigLDAP] = map[string]any{
|
||||
|
||||
@@ -147,6 +147,12 @@ const (
|
||||
SupportSettingsDefaultSupportEmail = ""
|
||||
SupportSettingsDefaultReAcceptancePeriod = 365
|
||||
|
||||
SupportSettingsReportAProblemTypeLink = "link"
|
||||
SupportSettingsReportAProblemTypeMail = "email"
|
||||
SupportSettingsReportAProblemTypeHidden = "hidden"
|
||||
SupportSettingsReportAProblemTypeDefault = "default"
|
||||
SupportSettingsDefaultReportAProblemType = SupportSettingsReportAProblemTypeDefault
|
||||
|
||||
LdapSettingsDefaultFirstNameAttribute = ""
|
||||
LdapSettingsDefaultLastNameAttribute = ""
|
||||
LdapSettingsDefaultEmailAttribute = ""
|
||||
@@ -2146,6 +2152,9 @@ type SupportSettings struct {
|
||||
AboutLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
||||
HelpLink *string `access:"site_customization"`
|
||||
ReportAProblemLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
||||
ReportAProblemType *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
||||
ReportAProblemMail *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
||||
AllowDownloadLogs *bool `access:"site_customization,write_restrictable,cloud_restrictable"`
|
||||
ForgotPasswordLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
||||
SupportEmail *string `access:"site_notifications"`
|
||||
CustomTermsOfServiceEnabled *bool `access:"compliance_custom_terms_of_service"`
|
||||
@@ -2194,6 +2203,18 @@ func (s *SupportSettings) SetDefaults() {
|
||||
s.ReportAProblemLink = NewPointer(SupportSettingsDefaultReportAProblemLink)
|
||||
}
|
||||
|
||||
if s.ReportAProblemType == nil {
|
||||
s.ReportAProblemType = NewPointer(SupportSettingsDefaultReportAProblemType)
|
||||
}
|
||||
|
||||
if s.ReportAProblemMail == nil {
|
||||
s.ReportAProblemMail = NewPointer("")
|
||||
}
|
||||
|
||||
if s.AllowDownloadLogs == nil {
|
||||
s.AllowDownloadLogs = NewPointer(true)
|
||||
}
|
||||
|
||||
if !isSafeLink(s.ForgotPasswordLink) {
|
||||
*s.ForgotPasswordLink = ""
|
||||
}
|
||||
@@ -3987,6 +4008,26 @@ func (o *Config) IsValid() *AppError {
|
||||
return appErr
|
||||
}
|
||||
|
||||
if o.SupportSettings.ReportAProblemType != nil {
|
||||
if *o.SupportSettings.ReportAProblemType == SupportSettingsReportAProblemTypeMail {
|
||||
if o.SupportSettings.ReportAProblemMail == nil {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.report_a_problem_mail.missing.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
if !IsValidEmail(*o.SupportSettings.ReportAProblemMail) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.report_a_problem_mail.invalid.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
if *o.SupportSettings.ReportAProblemType == SupportSettingsReportAProblemTypeLink {
|
||||
if o.SupportSettings.ReportAProblemLink == nil {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.report_a_problem_link.missing.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if !IsValidHTTPURL(*o.SupportSettings.ReportAProblemLink) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.report_a_problem_link.invalid.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,52 @@ func TestConfigDefaults(t *testing.T) {
|
||||
c.SetDefaults()
|
||||
recursivelyUninitialize(&c, "config", reflect.ValueOf(&c).Elem())
|
||||
})
|
||||
t.Run("report a problem defaults", func(t *testing.T) {
|
||||
c := Config{}
|
||||
c.SetDefaults()
|
||||
require.Equal(t, SupportSettingsDefaultReportAProblemType, *c.SupportSettings.ReportAProblemType)
|
||||
require.Equal(t, SupportSettingsDefaultReportAProblemLink, *c.SupportSettings.ReportAProblemLink)
|
||||
require.Equal(t, "", *c.SupportSettings.ReportAProblemMail)
|
||||
require.Equal(t, true, *c.SupportSettings.AllowDownloadLogs)
|
||||
})
|
||||
}
|
||||
|
||||
func TestConfigIsValid(t *testing.T) {
|
||||
t.Run("report a problem values", func(t *testing.T) {
|
||||
t.Run("email", func(t *testing.T) {
|
||||
c := Config{}
|
||||
c.SetDefaults()
|
||||
c.SupportSettings.ReportAProblemType = NewPointer(string(SupportSettingsReportAProblemTypeMail))
|
||||
c.SupportSettings.ReportAProblemMail = nil
|
||||
require.NotNil(t, c.IsValid())
|
||||
|
||||
c.SupportSettings.ReportAProblemMail = NewPointer("")
|
||||
require.NotNil(t, c.IsValid())
|
||||
|
||||
c.SupportSettings.ReportAProblemMail = NewPointer("invalid")
|
||||
require.NotNil(t, c.IsValid())
|
||||
|
||||
c.SupportSettings.ReportAProblemMail = NewPointer("valid@email.com")
|
||||
require.Nil(t, c.IsValid())
|
||||
})
|
||||
|
||||
t.Run("link", func(t *testing.T) {
|
||||
c := Config{}
|
||||
c.SetDefaults()
|
||||
c.SupportSettings.ReportAProblemType = NewPointer(string(SupportSettingsReportAProblemTypeLink))
|
||||
c.SupportSettings.ReportAProblemLink = nil
|
||||
require.NotNil(t, c.IsValid())
|
||||
|
||||
c.SupportSettings.ReportAProblemLink = NewPointer("")
|
||||
require.NotNil(t, c.IsValid())
|
||||
|
||||
c.SupportSettings.ReportAProblemLink = NewPointer("invalid")
|
||||
require.NotNil(t, c.IsValid())
|
||||
|
||||
c.SupportSettings.ReportAProblemLink = NewPointer("http://valid.com")
|
||||
require.Nil(t, c.IsValid())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestConfigEmptySiteName(t *testing.T) {
|
||||
|
||||
@@ -189,6 +189,7 @@
|
||||
"AboutLink": "https://mattermost.com/default-about/",
|
||||
"HelpLink": "https://mattermost.com/pl/help/",
|
||||
"ReportAProblemLink": "https://mattermost.com/pl/report-a-bug",
|
||||
"ReportAProblemType": "link",
|
||||
"ForgotPasswordLink": "",
|
||||
"SupportEmail": "feedback@mattermost.com"
|
||||
},
|
||||
|
||||
Ссылка в новой задаче
Block a user