MM-25563: Add endpoint to fetch only archived channels (#15031)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
29c8b58fc7
Коммит
77f7a97bee
@@ -618,7 +618,7 @@ func testChannelStoreDelete(t *testing.T, ss store.Store) {
|
||||
nErr = ss.Channel().Delete(o3.Id, model.GetMillis())
|
||||
require.Nil(t, nErr, nErr)
|
||||
|
||||
list, nErr := ss.Channel().GetChannels(o1.TeamId, m1.UserId, false)
|
||||
list, nErr := ss.Channel().GetChannels(o1.TeamId, m1.UserId, false, 0)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, *list, 1, "invalid number of channels")
|
||||
|
||||
@@ -629,7 +629,7 @@ func testChannelStoreDelete(t *testing.T, ss store.Store) {
|
||||
cresult := ss.Channel().PermanentDelete(o2.Id)
|
||||
require.Nil(t, cresult)
|
||||
|
||||
list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, false)
|
||||
list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, false, 0)
|
||||
if assert.NotNil(t, nErr) {
|
||||
var nfErr *store.ErrNotFound
|
||||
require.True(t, errors.As(nErr, &nfErr))
|
||||
@@ -3111,20 +3111,29 @@ func testChannelDeleteMemberStore(t *testing.T, ss store.Store) {
|
||||
}
|
||||
|
||||
func testChannelStoreGetChannels(t *testing.T, ss store.Store) {
|
||||
o2 := model.Channel{}
|
||||
o2.TeamId = model.NewId()
|
||||
o2.DisplayName = "Channel2"
|
||||
o2.Name = "zz" + model.NewId() + "b"
|
||||
o2.Type = model.CHANNEL_OPEN
|
||||
_, nErr := ss.Channel().Save(&o2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
team := model.NewId()
|
||||
o1 := model.Channel{}
|
||||
o1.TeamId = model.NewId()
|
||||
o1.TeamId = team
|
||||
o1.DisplayName = "Channel1"
|
||||
o1.Name = "zz" + model.NewId() + "b"
|
||||
o1.Type = model.CHANNEL_OPEN
|
||||
_, nErr = ss.Channel().Save(&o1, -1)
|
||||
_, nErr := ss.Channel().Save(&o1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
o2 := model.Channel{}
|
||||
o2.TeamId = team
|
||||
o2.DisplayName = "Channel2"
|
||||
o2.Name = "zz" + model.NewId() + "b"
|
||||
o2.Type = model.CHANNEL_OPEN
|
||||
_, nErr = ss.Channel().Save(&o2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
o3 := model.Channel{}
|
||||
o3.TeamId = team
|
||||
o3.DisplayName = "Channel3"
|
||||
o3.Name = "zz" + model.NewId() + "b"
|
||||
o3.Type = model.CHANNEL_OPEN
|
||||
_, nErr = ss.Channel().Save(&o3, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
m1 := model.ChannelMember{}
|
||||
@@ -3143,14 +3152,24 @@ func testChannelStoreGetChannels(t *testing.T, ss store.Store) {
|
||||
|
||||
m3 := model.ChannelMember{}
|
||||
m3.ChannelId = o2.Id
|
||||
m3.UserId = model.NewId()
|
||||
m3.UserId = m1.UserId
|
||||
m3.NotifyProps = model.GetDefaultChannelNotifyProps()
|
||||
_, err = ss.Channel().SaveMember(&m3)
|
||||
require.Nil(t, err)
|
||||
|
||||
list, nErr := ss.Channel().GetChannels(o1.TeamId, m1.UserId, false)
|
||||
m4 := model.ChannelMember{}
|
||||
m4.ChannelId = o3.Id
|
||||
m4.UserId = m1.UserId
|
||||
m4.NotifyProps = model.GetDefaultChannelNotifyProps()
|
||||
_, err = ss.Channel().SaveMember(&m4)
|
||||
require.Nil(t, err)
|
||||
|
||||
list, nErr := ss.Channel().GetChannels(o1.TeamId, m1.UserId, false, 0)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, *list, 3)
|
||||
require.Equal(t, o1.Id, (*list)[0].Id, "missing channel")
|
||||
require.Equal(t, o2.Id, (*list)[1].Id, "missing channel")
|
||||
require.Equal(t, o3.Id, (*list)[2].Id, "missing channel")
|
||||
|
||||
ids, err := ss.Channel().GetAllChannelMembersForUser(m1.UserId, false, false)
|
||||
require.Nil(t, err)
|
||||
@@ -3172,11 +3191,46 @@ func testChannelStoreGetChannels(t *testing.T, ss store.Store) {
|
||||
_, ok = ids4[o1.Id]
|
||||
require.True(t, ok, "missing channel")
|
||||
|
||||
nErr = ss.Channel().Delete(o2.Id, 10)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
nErr = ss.Channel().Delete(o3.Id, 20)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
// should return 1
|
||||
list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, false, 0)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, *list, 1)
|
||||
require.Equal(t, o1.Id, (*list)[0].Id, "missing channel")
|
||||
|
||||
// Should return all
|
||||
list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, true, 0)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, *list, 3)
|
||||
require.Equal(t, o1.Id, (*list)[0].Id, "missing channel")
|
||||
require.Equal(t, o2.Id, (*list)[1].Id, "missing channel")
|
||||
require.Equal(t, o3.Id, (*list)[2].Id, "missing channel")
|
||||
|
||||
// Should still return all
|
||||
list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, true, 10)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, *list, 3)
|
||||
require.Equal(t, o1.Id, (*list)[0].Id, "missing channel")
|
||||
require.Equal(t, o2.Id, (*list)[1].Id, "missing channel")
|
||||
require.Equal(t, o3.Id, (*list)[2].Id, "missing channel")
|
||||
|
||||
// Should return 2
|
||||
list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, true, 20)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, *list, 2)
|
||||
require.Equal(t, o1.Id, (*list)[0].Id, "missing channel")
|
||||
require.Equal(t, o3.Id, (*list)[1].Id, "missing channel")
|
||||
|
||||
require.True(
|
||||
t,
|
||||
ss.Channel().IsUserInChannelUseCache(m1.UserId, o1.Id),
|
||||
"missing channel")
|
||||
require.False(
|
||||
require.True(
|
||||
t,
|
||||
ss.Channel().IsUserInChannelUseCache(m1.UserId, o2.Id),
|
||||
"missing channel")
|
||||
|
||||
@@ -638,13 +638,13 @@ func (_m *ChannelStore) GetChannelUnread(channelId string, userId string) (*mode
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetChannels provides a mock function with given fields: teamId, userId, includeDeleted
|
||||
func (_m *ChannelStore) GetChannels(teamId string, userId string, includeDeleted bool) (*model.ChannelList, error) {
|
||||
ret := _m.Called(teamId, userId, includeDeleted)
|
||||
// GetChannels provides a mock function with given fields: teamId, userId, includeDeleted, lastDeleteAt
|
||||
func (_m *ChannelStore) GetChannels(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error) {
|
||||
ret := _m.Called(teamId, userId, includeDeleted, lastDeleteAt)
|
||||
|
||||
var r0 *model.ChannelList
|
||||
if rf, ok := ret.Get(0).(func(string, string, bool) *model.ChannelList); ok {
|
||||
r0 = rf(teamId, userId, includeDeleted)
|
||||
if rf, ok := ret.Get(0).(func(string, string, bool, int) *model.ChannelList); ok {
|
||||
r0 = rf(teamId, userId, includeDeleted, lastDeleteAt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.ChannelList)
|
||||
@@ -652,8 +652,8 @@ func (_m *ChannelStore) GetChannels(teamId string, userId string, includeDeleted
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, string, bool) error); ok {
|
||||
r1 = rf(teamId, userId, includeDeleted)
|
||||
if rf, ok := ret.Get(1).(func(string, string, bool, int) error); ok {
|
||||
r1 = rf(teamId, userId, includeDeleted, lastDeleteAt)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user