MM-23596: Ability to list private channels for team (#14925)
Summary: store, app, api and go driver support for listing private channels Ticket Link: https://mattermost.atlassian.net/browse/MM-23596
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a4fc0fcfb7
Коммит
af8b914c6c
@@ -611,6 +611,7 @@ type AppIface interface {
|
||||
GetPreferenceByCategoryForUser(userId string, category string) (model.Preferences, *model.AppError)
|
||||
GetPreferencesForUser(userId string) (model.Preferences, *model.AppError)
|
||||
GetPrevPostIdFromPostList(postList *model.PostList) string
|
||||
GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetProfileImage(user *model.User) ([]byte, bool, *model.AppError)
|
||||
GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError)
|
||||
GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
|
||||
@@ -1635,6 +1635,10 @@ func (a *App) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*m
|
||||
return a.Srv().Store.Channel().GetPublicChannelsForTeam(teamId, offset, limit)
|
||||
}
|
||||
|
||||
func (a *App) GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
return a.Srv().Store.Channel().GetPrivateChannelsForTeam(teamId, offset, limit)
|
||||
}
|
||||
|
||||
func (a *App) GetChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
|
||||
return a.Srv().Store.Channel().GetMember(channelId, userId)
|
||||
}
|
||||
|
||||
@@ -924,6 +924,39 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
|
||||
assert.ElementsMatch(t, expectedChannels, channels)
|
||||
}
|
||||
|
||||
func TestGetPrivateChannelsForTeam(t *testing.T) {
|
||||
th := Setup(t)
|
||||
team := th.CreateTeam()
|
||||
defer th.TearDown()
|
||||
|
||||
var expectedChannels []*model.Channel
|
||||
for i := 0; i < 8; i++ {
|
||||
channel := model.Channel{
|
||||
DisplayName: fmt.Sprintf("Private %v", i),
|
||||
Name: fmt.Sprintf("private_%v", i),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
TeamId: team.Id,
|
||||
}
|
||||
var rchannel *model.Channel
|
||||
rchannel, err := th.App.CreateChannel(&channel, false)
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, rchannel)
|
||||
defer th.App.PermanentDeleteChannel(rchannel)
|
||||
|
||||
// Store the user ids for comparison later
|
||||
expectedChannels = append(expectedChannels, rchannel)
|
||||
}
|
||||
|
||||
// Fetch private channels multipile times
|
||||
channelList, err := th.App.GetPrivateChannelsForTeam(team.Id, 0, 5)
|
||||
require.Nil(t, err)
|
||||
channelList2, err := th.App.GetPrivateChannelsForTeam(team.Id, 5, 5)
|
||||
require.Nil(t, err)
|
||||
|
||||
channels := append(*channelList, *channelList2...)
|
||||
assert.ElementsMatch(t, expectedChannels, channels)
|
||||
}
|
||||
|
||||
func TestUpdateChannelMemberRolesChangingGuest(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -6987,6 +6987,28 @@ func (a *OpenTracingAppLayer) GetPrevPostIdFromPostList(postList *model.PostList
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPrivateChannelsForTeam")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store.SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store.SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetPrivateChannelsForTeam(teamId, offset, limit)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetProfileImage(user *model.User) ([]byte, bool, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetProfileImage")
|
||||
|
||||
Ссылка в новой задаче
Block a user