[MM-56904] Reduce the number of api requests made to fetch user information for GMs on page load (#27149)
* use new endpoint to fetch group members
Этот коммит содержится в:
@@ -8,37 +8,38 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
JobTypeDataRetention = "data_retention"
|
||||
JobTypeMessageExport = "message_export"
|
||||
JobTypeElasticsearchPostIndexing = "elasticsearch_post_indexing"
|
||||
JobTypeElasticsearchPostAggregation = "elasticsearch_post_aggregation"
|
||||
JobTypeBlevePostIndexing = "bleve_post_indexing"
|
||||
JobTypeLdapSync = "ldap_sync"
|
||||
JobTypeMigrations = "migrations"
|
||||
JobTypePlugins = "plugins"
|
||||
JobTypeExpiryNotify = "expiry_notify"
|
||||
JobTypeProductNotices = "product_notices"
|
||||
JobTypeActiveUsers = "active_users"
|
||||
JobTypeImportProcess = "import_process"
|
||||
JobTypeImportDelete = "import_delete"
|
||||
JobTypeExportProcess = "export_process"
|
||||
JobTypeExportDelete = "export_delete"
|
||||
JobTypeCloud = "cloud"
|
||||
JobTypeResendInvitationEmail = "resend_invitation_email"
|
||||
JobTypeExtractContent = "extract_content"
|
||||
JobTypeLastAccessiblePost = "last_accessible_post"
|
||||
JobTypeLastAccessibleFile = "last_accessible_file"
|
||||
JobTypeUpgradeNotifyAdmin = "upgrade_notify_admin"
|
||||
JobTypeTrialNotifyAdmin = "trial_notify_admin"
|
||||
JobTypePostPersistentNotifications = "post_persistent_notifications"
|
||||
JobTypeInstallPluginNotifyAdmin = "install_plugin_notify_admin"
|
||||
JobTypeHostedPurchaseScreening = "hosted_purchase_screening"
|
||||
JobTypeS3PathMigration = "s3_path_migration"
|
||||
JobTypeCleanupDesktopTokens = "cleanup_desktop_tokens"
|
||||
JobTypeDeleteEmptyDraftsMigration = "delete_empty_drafts_migration"
|
||||
JobTypeRefreshPostStats = "refresh_post_stats"
|
||||
JobTypeDeleteOrphanDraftsMigration = "delete_orphan_drafts_migration"
|
||||
JobTypeExportUsersToCSV = "export_users_to_csv"
|
||||
JobTypeDataRetention = "data_retention"
|
||||
JobTypeMessageExport = "message_export"
|
||||
JobTypeElasticsearchPostIndexing = "elasticsearch_post_indexing"
|
||||
JobTypeElasticsearchPostAggregation = "elasticsearch_post_aggregation"
|
||||
JobTypeBlevePostIndexing = "bleve_post_indexing"
|
||||
JobTypeLdapSync = "ldap_sync"
|
||||
JobTypeMigrations = "migrations"
|
||||
JobTypePlugins = "plugins"
|
||||
JobTypeExpiryNotify = "expiry_notify"
|
||||
JobTypeProductNotices = "product_notices"
|
||||
JobTypeActiveUsers = "active_users"
|
||||
JobTypeImportProcess = "import_process"
|
||||
JobTypeImportDelete = "import_delete"
|
||||
JobTypeExportProcess = "export_process"
|
||||
JobTypeExportDelete = "export_delete"
|
||||
JobTypeCloud = "cloud"
|
||||
JobTypeResendInvitationEmail = "resend_invitation_email"
|
||||
JobTypeExtractContent = "extract_content"
|
||||
JobTypeLastAccessiblePost = "last_accessible_post"
|
||||
JobTypeLastAccessibleFile = "last_accessible_file"
|
||||
JobTypeUpgradeNotifyAdmin = "upgrade_notify_admin"
|
||||
JobTypeTrialNotifyAdmin = "trial_notify_admin"
|
||||
JobTypePostPersistentNotifications = "post_persistent_notifications"
|
||||
JobTypeInstallPluginNotifyAdmin = "install_plugin_notify_admin"
|
||||
JobTypeHostedPurchaseScreening = "hosted_purchase_screening"
|
||||
JobTypeS3PathMigration = "s3_path_migration"
|
||||
JobTypeCleanupDesktopTokens = "cleanup_desktop_tokens"
|
||||
JobTypeDeleteEmptyDraftsMigration = "delete_empty_drafts_migration"
|
||||
JobTypeRefreshPostStats = "refresh_post_stats"
|
||||
JobTypeDeleteOrphanDraftsMigration = "delete_orphan_drafts_migration"
|
||||
JobTypeExportUsersToCSV = "export_users_to_csv"
|
||||
JobTypeDeleteDmsPreferencesMigration = "delete_dms_preferences_migration"
|
||||
|
||||
JobStatusPending = "pending"
|
||||
JobStatusInProgress = "in_progress"
|
||||
|
||||
@@ -47,5 +47,6 @@ const (
|
||||
MigrationKeyAddIPFilteringPermissions = "add_ip_filtering_permissions"
|
||||
MigrationKeyAddOutgoingOAuthConnectionsPermissions = "add_outgoing_oauth_connections_permissions"
|
||||
MigrationKeyAddChannelBookmarksPermissions = "add_channel_bookmarks_permissions"
|
||||
MigrationKeyDeleteDmsPreferences = "delete_dms_preferences_migration"
|
||||
MigrationKeyAddManageJobAncillaryPermissions = "add_manage_jobs_ancillary_permissions"
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
@@ -61,7 +62,9 @@ const (
|
||||
PreferenceEmailIntervalHourAsSeconds = "3600"
|
||||
PreferenceCloudUserEphemeralInfo = "cloud_user_ephemeral_info"
|
||||
|
||||
MaxPreferenceValueLength = 20000
|
||||
PreferenceLimitVisibleDmsGms = "limit_visible_dms_gms"
|
||||
PreferenceMaxLimitVisibleDmsGmsValue = 40
|
||||
MaxPreferenceValueLength = 20000
|
||||
)
|
||||
|
||||
type Preference struct {
|
||||
@@ -97,6 +100,13 @@ func (o *Preference) IsValid() *AppError {
|
||||
}
|
||||
}
|
||||
|
||||
if o.Category == PreferenceCategorySidebarSettings && o.Name == PreferenceLimitVisibleDmsGms {
|
||||
visibleDmsGmsValue, convErr := strconv.Atoi(o.Value)
|
||||
if convErr != nil || visibleDmsGmsValue < 1 || visibleDmsGmsValue > PreferenceMaxLimitVisibleDmsGmsValue {
|
||||
return NewAppError("Preference.IsValid", "model.preference.is_valid.limit_visible_dms_gms.app_error", nil, "value="+o.Value, http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,34 @@ func TestPreferenceIsValid(t *testing.T) {
|
||||
|
||||
require.Nil(t, preference.IsValid())
|
||||
})
|
||||
|
||||
t.Run("limit_visible_dms_gms has a valid value", func(t *testing.T) {
|
||||
preference.Category = PreferenceCategorySidebarSettings
|
||||
preference.Name = PreferenceLimitVisibleDmsGms
|
||||
preference.Value = "40"
|
||||
require.Nil(t, preference.IsValid())
|
||||
})
|
||||
|
||||
t.Run("limit_visible_dms_gms has a value greater than PreferenceMaxLimitVisibleDmsGmsValue", func(t *testing.T) {
|
||||
preference.Category = PreferenceCategorySidebarSettings
|
||||
preference.Name = PreferenceLimitVisibleDmsGms
|
||||
preference.Value = "10000"
|
||||
require.NotNil(t, preference.IsValid())
|
||||
})
|
||||
|
||||
t.Run("limit_visible_dms_gms has an invalid value", func(t *testing.T) {
|
||||
preference.Category = PreferenceCategorySidebarSettings
|
||||
preference.Name = PreferenceLimitVisibleDmsGms
|
||||
preference.Value = "one thousand"
|
||||
require.NotNil(t, preference.IsValid())
|
||||
})
|
||||
|
||||
t.Run("limit_visible_dms_gms has a negative number", func(t *testing.T) {
|
||||
preference.Category = PreferenceCategorySidebarSettings
|
||||
preference.Name = PreferenceLimitVisibleDmsGms
|
||||
preference.Value = "-10"
|
||||
require.NotNil(t, preference.IsValid())
|
||||
})
|
||||
}
|
||||
|
||||
func TestPreferencePreUpdate(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user