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
@@ -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) {
|
||||
|
||||
Ссылка в новой задаче
Block a user