Merge branch 'master' of github.com:mattermost/mattermost-server into MM-49474-add-downgrade-feedback

Этот коммит содержится в:
Conor Macpherson
2023-01-13 15:14:03 -05:00
родитель a13fda6b61 5ae6d6e108
Коммит 2e04003fc2
27 изменённых файлов: 239 добавлений и 199 удалений

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

@@ -10,6 +10,7 @@ import (
"errors"
"io"
"net/http"
"regexp"
"sort"
"strings"
"unicode/utf8"
@@ -159,7 +160,7 @@ type ChannelModeratedRolesPatch struct {
type ChannelSearchOpts struct {
NotAssociatedToGroup string
ExcludeDefaultChannels bool
IncludeDeleted bool
IncludeDeleted bool // If true, deleted channels will be included in the results.
Deleted bool
ExcludeChannelNames []string
TeamIds []string
@@ -173,7 +174,7 @@ type ChannelSearchOpts struct {
Private bool
Page *int
PerPage *int
LastDeleteAt int
LastDeleteAt int // When combined with IncludeDeleted, only channels deleted after this time will be returned.
LastUpdateAt int
}
@@ -185,6 +186,8 @@ type ChannelMemberCountByGroup struct {
type ChannelOption func(channel *Channel)
var gmNameRegex = regexp.MustCompile("^[a-f0-9]{40}$")
func WithID(ID string) ChannelOption {
return func(channel *Channel) {
channel.Id = ID
@@ -281,9 +284,11 @@ func (o *Channel) IsValid() *AppError {
return NewAppError("Channel.IsValid", "model.channel.is_valid.creator_id.app_error", nil, "", http.StatusBadRequest)
}
userIds := strings.Split(o.Name, "__")
if o.Type != ChannelTypeDirect && len(userIds) == 2 && IsValidId(userIds[0]) && IsValidId(userIds[1]) {
return NewAppError("Channel.IsValid", "model.channel.is_valid.name.app_error", nil, "", http.StatusBadRequest)
if o.Type != ChannelTypeDirect && o.Type != ChannelTypeGroup {
userIds := strings.Split(o.Name, "__")
if ok := gmNameRegex.MatchString(o.Name); ok || (o.Type != ChannelTypeDirect && len(userIds) == 2 && IsValidId(userIds[0]) && IsValidId(userIds[1])) {
return NewAppError("Channel.IsValid", "model.channel.is_valid.name.app_error", nil, "", http.StatusBadRequest)
}
}
return nil

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

@@ -79,6 +79,12 @@ func TestChannelIsValid(t *testing.T) {
o.Purpose = strings.Repeat("0123456789", 25)
require.Nil(t, o.IsValid())
o.Name = "beu8cc6b3jnxfe9r4na9baooma__36atajbs87dqmpym6o8eiy9saa"
require.NotNil(t, o.IsValid())
o.Name = "71b03afcbb2d503d49f87f057549c43db4e19f92"
require.NotNil(t, o.IsValid())
}
func TestChannelPreSave(t *testing.T) {

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

@@ -385,6 +385,7 @@ type ServiceSettings struct {
EnableCustomGroups *bool `access:"site_users_and_teams"`
SelfHostedPurchase *bool `access:"write_restrictable,cloud_restrictable"`
AllowSyncedDrafts *bool `access:"site_posts"`
ExperimentalMaxUserPreferences *int
}
func (s *ServiceSettings) SetDefaults(isUpdate bool) {
@@ -857,6 +858,10 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
if s.SelfHostedPurchase == nil {
s.SelfHostedPurchase = NewBool(true)
}
if s.ExperimentalMaxUserPreferences == nil {
s.ExperimentalMaxUserPreferences = NewInt(1000)
}
}
type ClusterSettings struct {
@@ -2867,8 +2872,8 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
}
if s.PluginStates[PluginIdFocalboard] == nil {
// Disable the focalboard plugin by default
s.PluginStates[PluginIdFocalboard] = &PluginState{Enable: false}
// Enable the focalboard plugin by default
s.PluginStates[PluginIdFocalboard] = &PluginState{Enable: true}
}
if s.PluginStates[PluginIdApps] == nil {

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

@@ -387,11 +387,11 @@ func TestConfigDefaultChannelExportPluginState(t *testing.T) {
}
func TestConfigDefaultFocalboardPluginState(t *testing.T) {
t.Run("should not enable Focalboard plugin by default", func(t *testing.T) {
t.Run("should enable Focalboard plugin by default", func(t *testing.T) {
c1 := Config{}
c1.SetDefaults()
assert.False(t, c1.PluginSettings.PluginStates["focalboard"].Enable)
assert.True(t, c1.PluginSettings.PluginStates["focalboard"].Enable)
})
t.Run("should not re-enable focalboard plugin after it has been disabled", func(t *testing.T) {

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

@@ -95,7 +95,7 @@ func (f *FeatureFlags) SetDefaults() {
f.InsightsEnabled = true
f.CommandPalette = false
f.CallsEnabled = true
f.BoardsProduct = true
f.BoardsProduct = false
f.SendWelcomePost = true
f.PostPriority = true
f.PeopleProduct = false