MM-14897: Changes to be able to add and remove groups from channels. (#10794)
* MM-15162: Changes for LDAP groups removals phase. * MM-14897: Changes to be able to add and remove groups from channels. * Update model/client4.go * MM-14897: PR-requested change to string interpolation.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
dd33bc13a7
Коммит
1b78f9debc
16
app/group.go
16
app/group.go
@@ -165,12 +165,20 @@ func (a *App) ChannelMembersToRemove() ([]*model.ChannelMember, *model.AppError)
|
||||
return result.Data.([]*model.ChannelMember), nil
|
||||
}
|
||||
|
||||
func (a *App) GetGroupsByChannel(channelId string, page, perPage int) ([]*model.Group, *model.AppError) {
|
||||
result := <-a.Srv.Store.Group().GetGroupsByChannel(channelId, page, perPage)
|
||||
func (a *App) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||
result := <-a.Srv.Store.Group().GetGroupsByChannel(channelId, opts)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
return nil, 0, result.Err
|
||||
}
|
||||
return result.Data.([]*model.Group), nil
|
||||
groups := result.Data.([]*model.Group)
|
||||
|
||||
result = <-a.Srv.Store.Group().CountGroupsByChannel(channelId, opts)
|
||||
if result.Err != nil {
|
||||
return nil, 0, result.Err
|
||||
}
|
||||
count := result.Data.(int64)
|
||||
|
||||
return groups, int(count), nil
|
||||
}
|
||||
|
||||
func (a *App) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||
|
||||
@@ -215,11 +215,18 @@ func TestGetGroupsByChannel(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, gs)
|
||||
|
||||
groups, err := th.App.GetGroupsByChannel(th.BasicChannel.Id, 0, 60)
|
||||
opts := model.GroupSearchOpts{
|
||||
PageOpts: &model.PageOpts{
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
},
|
||||
}
|
||||
|
||||
groups, _, err := th.App.GetGroupsByChannel(th.BasicChannel.Id, opts)
|
||||
require.Nil(t, err)
|
||||
require.ElementsMatch(t, []*model.Group{group}, groups)
|
||||
|
||||
groups, err = th.App.GetGroupsByChannel(model.NewId(), 0, 60)
|
||||
groups, _, err = th.App.GetGroupsByChannel(model.NewId(), opts)
|
||||
require.Nil(t, err)
|
||||
require.Empty(t, groups)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user