[release-10.11] Restrict group_constrained to channels that support group sync (#36916)

Automatic Merge
Этот коммит содержится в:
Maria A Nunez
2026-06-05 03:29:59 -04:00
коммит произвёл GitHub
родитель 56098dd6f0
Коммит beaa59db54
6 изменённых файлов: 95 добавлений и 0 удалений

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

@@ -345,6 +345,11 @@ func patchChannel(c *Context, w http.ResponseWriter, r *http.Request) {
model.AddEventParameterAuditableToAuditRec(auditRec, "channel", patch)
auditRec.AddEventPriorState(oldChannel)
if patch.GroupConstrained != nil && !oldChannel.SupportsGroupSync() {
c.Err = model.NewAppError("patchChannel", "api.channel.patch_update_channel.group_constrained_not_allowed.app_error", nil, "", http.StatusBadRequest)
return
}
switch oldChannel.Type {
case model.ChannelTypeOpen:
if ok, _ := c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), c.Params.ChannelId, model.PermissionManagePublicChannelProperties); !ok {

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

@@ -872,6 +872,36 @@ func TestPatchChannel(t *testing.T) {
CheckBadRequestStatus(t, resp)
})
t.Run("Should block setting group_constrained on group and direct messages", func(t *testing.T) {
user1 := th.CreateUser()
user2 := th.CreateUser()
user3 := th.CreateUser()
_, err := client.Logout(context.Background())
require.NoError(t, err)
_, _, err = client.Login(context.Background(), user1.Email, user1.Password)
require.NoError(t, err)
groupChannel, _, err := client.CreateGroupChannel(context.Background(), []string{user1.Id, user2.Id, user3.Id})
require.NoError(t, err)
patch := &model.ChannelPatch{GroupConstrained: model.NewPointer(true)}
_, resp, err := client.PatchChannel(context.Background(), groupChannel.Id, patch)
require.Error(t, err)
CheckBadRequestStatus(t, resp)
stats, _, err := client.GetChannelStats(context.Background(), groupChannel.Id, "", false)
require.NoError(t, err)
require.Equal(t, int64(3), stats.MemberCount)
directChannel, _, err := client.CreateDirectChannel(context.Background(), user1.Id, user2.Id)
require.NoError(t, err)
_, resp, err = client.PatchChannel(context.Background(), directChannel.Id, patch)
require.Error(t, err)
CheckBadRequestStatus(t, resp)
})
t.Run("Should not be able to configure channel banner without a license", func(t *testing.T) {
_, err := client.Logout(context.Background())
require.NoError(t, err)