mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-53107 Add setting to limit the max number of markdown nodes (#24414)
* MM-53107 Add setting to limit the max number of markdown nodes * Add extra validation for a couple config fields * Add new setting to telemetry
This commit is contained in:
parent
47b51ff696
commit
f2fcf3d839
@ -130,6 +130,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
|
||||
props["DataRetentionFileRetentionDays"] = "0"
|
||||
|
||||
props["CustomUrlSchemes"] = strings.Join(c.DisplaySettings.CustomURLSchemes, ",")
|
||||
props["MaxMarkdownNodes"] = strconv.FormatInt(int64(*c.DisplaySettings.MaxMarkdownNodes), 10)
|
||||
props["IsDefaultMarketplace"] = strconv.FormatBool(*c.PluginSettings.MarketplaceURL == model.PluginSettingsDefaultMarketplaceURL)
|
||||
props["ExperimentalSharedChannels"] = "false"
|
||||
props["CollapsedThreads"] = *c.ServiceSettings.CollapsedThreads
|
||||
|
@ -8643,6 +8643,10 @@
|
||||
"id": "model.config.is_valid.ldap_username",
|
||||
"translation": "AD/LDAP field \"Username Attribute\" is required."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.link_metadata_timeout.app_error",
|
||||
"translation": "Invalid value for link metadata timeout. Must be a positive number."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.listen_address.app_error",
|
||||
"translation": "Invalid listen address for service settings Must be set."
|
||||
@ -8863,6 +8867,10 @@
|
||||
"id": "model.config.is_valid.tls_overwrite_cipher.app_error",
|
||||
"translation": "Invalid value passed for TLS overwrite cipher - Please refer to the documentation for valid values."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.user_status_away_timeout.app_error",
|
||||
"translation": "Invalid value for user status away timeout. Must be a positive number."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.webserver_security.app_error",
|
||||
"translation": "Invalid value for webserver connection security."
|
||||
|
@ -855,6 +855,7 @@ func (ts *TelemetryService) trackConfig() {
|
||||
ts.SendTelemetry(TrackConfigDisplay, map[string]any{
|
||||
"experimental_timezone": *cfg.DisplaySettings.ExperimentalTimezone,
|
||||
"isdefault_custom_url_schemes": len(cfg.DisplaySettings.CustomURLSchemes) != 0,
|
||||
"isdefault_max_markdown_nodes": isDefault(*cfg.DisplaySettings.MaxMarkdownNodes, 0),
|
||||
})
|
||||
|
||||
ts.SendTelemetry(TrackConfigGuestAccounts, map[string]any{
|
||||
|
@ -3149,7 +3149,8 @@ func (s *MessageExportSettings) SetDefaults() {
|
||||
}
|
||||
|
||||
type DisplaySettings struct {
|
||||
CustomURLSchemes []string `access:"site_customization"`
|
||||
CustomURLSchemes []string `access:"site_posts"`
|
||||
MaxMarkdownNodes *int `access:"site_posts"`
|
||||
ExperimentalTimezone *bool `access:"experimental_features"`
|
||||
}
|
||||
|
||||
@ -3159,6 +3160,10 @@ func (s *DisplaySettings) SetDefaults() {
|
||||
s.CustomURLSchemes = customURLSchemes
|
||||
}
|
||||
|
||||
if s.MaxMarkdownNodes == nil {
|
||||
s.MaxMarkdownNodes = NewInt(0)
|
||||
}
|
||||
|
||||
if s.ExperimentalTimezone == nil {
|
||||
s.ExperimentalTimezone = NewBool(true)
|
||||
}
|
||||
@ -3502,6 +3507,10 @@ func (o *Config) IsValid() *AppError {
|
||||
return appErr
|
||||
}
|
||||
|
||||
if appErr := o.ExperimentalSettings.isValid(); appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
|
||||
if appErr := o.SqlSettings.isValid(); appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
@ -3577,6 +3586,10 @@ func (s *TeamSettings) isValid() *AppError {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.max_channels.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.UserStatusAwayTimeout <= 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.user_status_away_timeout.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.MaxNotificationsPerChannel <= 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.max_notify_per_channel.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@ -3596,6 +3609,14 @@ func (s *TeamSettings) isValid() *AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ExperimentalSettings) isValid() *AppError {
|
||||
if *s.LinkMetadataTimeoutMilliseconds <= 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.link_metadata_timeout.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SqlSettings) isValid() *AppError {
|
||||
if *s.AtRestEncryptKey != "" && len(*s.AtRestEncryptKey) < 32 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.encrypt_sql.app_error", nil, "", http.StatusBadRequest)
|
||||
|
@ -3056,6 +3056,15 @@ const AdminDefinition = {
|
||||
key: 'DisplaySettings.CustomURLSchemes',
|
||||
isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.SITE.POSTS)),
|
||||
},
|
||||
{
|
||||
type: Constants.SettingsTypes.TYPE_NUMBER,
|
||||
key: 'DisplaySettings.MaxMarkdownNodes',
|
||||
label: t('admin.customization.maxMarkdownNodesTitle'),
|
||||
label_default: 'Max Markdown Nodes:',
|
||||
help_text: t('admin.customization.maxMarkdownNodesDesc'),
|
||||
help_text_default: 'When rendering Markdown text in the mobile app, controls the maximum number of Markdown elements (eg. emojis, links, table cells, etc) that can be in a single piece of text. If set to 0, a default limit will be used.',
|
||||
isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.SITE.POSTS)),
|
||||
},
|
||||
{
|
||||
type: Constants.SettingsTypes.TYPE_TEXT,
|
||||
key: 'ServiceSettings.GoogleDeveloperKey',
|
||||
|
@ -447,7 +447,7 @@ export default class SchemaAdminSettings extends React.PureComponent {
|
||||
inputType = 'textarea';
|
||||
}
|
||||
|
||||
let value = this.state[setting.key] || '';
|
||||
let value = this.state[setting.key] ?? '';
|
||||
if (setting.dynamic_value) {
|
||||
value = setting.dynamic_value(value, this.props.config, this.state, this.props.license);
|
||||
}
|
||||
|
@ -667,6 +667,8 @@
|
||||
"admin.customization.enableSVGsTitle": "Enable SVGs:",
|
||||
"admin.customization.iosAppDownloadLinkDesc": "Add a link to download the iOS app. Users who access the site on a mobile web browser will be prompted with a page giving them the option to download the app. Leave this field blank to prevent the page from appearing.",
|
||||
"admin.customization.iosAppDownloadLinkTitle": "iOS App Download Link:",
|
||||
"admin.customization.maxMarkdownNodesDesc": "When rendering Markdown text in the mobile app, controls the maximum number of Markdown elements (eg. emojis, links, table cells, etc) that can be in a single piece of text. If set to 0, a default limit will be used.",
|
||||
"admin.customization.maxMarkdownNodesTitle": "Maximum Markdown Nodes:",
|
||||
"admin.customization.restrictLinkPreviewsDesc": "Link previews and image link previews will not be shown for the above list of comma-separated domains.",
|
||||
"admin.customization.restrictLinkPreviewsExample": "E.g.: \"internal.mycompany.com, images.example.com\"",
|
||||
"admin.customization.restrictLinkPreviewsTitle": "Disable website link previews from these domains:",
|
||||
|
Loading…
Reference in New Issue
Block a user