MM-26793 Fix accidentally removing other users' favorites again (#14995)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1302492874
Коммит
b0b9c707a6
@@ -3899,6 +3899,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
|
|||||||
// Remove any old favorites that might have been in this category
|
// Remove any old favorites that might have been in this category
|
||||||
sql, args, _ := s.getQueryBuilder().Delete("Preferences").Where(
|
sql, args, _ := s.getQueryBuilder().Delete("Preferences").Where(
|
||||||
sq.Eq{
|
sq.Eq{
|
||||||
|
"UserId": userId,
|
||||||
"Name": category.Channels,
|
"Name": category.Channels,
|
||||||
"Category": model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL,
|
"Category": model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7445,6 +7445,8 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
|
|
||||||
favoritesCategory := categories.Categories[0]
|
favoritesCategory := categories.Categories[0]
|
||||||
require.Equal(t, model.SidebarCategoryFavorites, favoritesCategory.Type)
|
require.Equal(t, model.SidebarCategoryFavorites, favoritesCategory.Type)
|
||||||
|
channelsCategory := categories.Categories[1]
|
||||||
|
require.Equal(t, model.SidebarCategoryChannels, channelsCategory.Type)
|
||||||
|
|
||||||
// Create the other users' categories
|
// Create the other users' categories
|
||||||
userId2 := model.NewId()
|
userId2 := model.NewId()
|
||||||
@@ -7457,6 +7459,8 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
|
|
||||||
favoritesCategory2 := categories2.Categories[0]
|
favoritesCategory2 := categories2.Categories[0]
|
||||||
require.Equal(t, model.SidebarCategoryFavorites, favoritesCategory2.Type)
|
require.Equal(t, model.SidebarCategoryFavorites, favoritesCategory2.Type)
|
||||||
|
channelsCategory2 := categories2.Categories[1]
|
||||||
|
require.Equal(t, model.SidebarCategoryChannels, channelsCategory2.Type)
|
||||||
|
|
||||||
// Have both users join a channel
|
// Have both users join a channel
|
||||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
@@ -7484,6 +7488,10 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
SidebarCategory: favoritesCategory.SidebarCategory,
|
SidebarCategory: favoritesCategory.SidebarCategory,
|
||||||
Channels: []string{channel.Id},
|
Channels: []string{channel.Id},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
SidebarCategory: channelsCategory.SidebarCategory,
|
||||||
|
Channels: []string{},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
@@ -7502,6 +7510,10 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
SidebarCategory: favoritesCategory2.SidebarCategory,
|
SidebarCategory: favoritesCategory2.SidebarCategory,
|
||||||
Channels: []string{channel.Id},
|
Channels: []string{channel.Id},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
SidebarCategory: channelsCategory2.SidebarCategory,
|
||||||
|
Channels: []string{},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
@@ -7517,6 +7529,10 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
|
|
||||||
// And then user1 unfavorite it
|
// And then user1 unfavorite it
|
||||||
_, err = ss.Channel().UpdateSidebarCategories(userId, teamId, []*model.SidebarCategoryWithChannels{
|
_, err = ss.Channel().UpdateSidebarCategories(userId, teamId, []*model.SidebarCategoryWithChannels{
|
||||||
|
{
|
||||||
|
SidebarCategory: channelsCategory.SidebarCategory,
|
||||||
|
Channels: []string{channel.Id},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
SidebarCategory: favoritesCategory.SidebarCategory,
|
SidebarCategory: favoritesCategory.SidebarCategory,
|
||||||
Channels: []string{},
|
Channels: []string{},
|
||||||
@@ -7535,6 +7551,10 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
|
|||||||
|
|
||||||
// And finally user2 favorite it
|
// And finally user2 favorite it
|
||||||
_, err = ss.Channel().UpdateSidebarCategories(userId2, teamId, []*model.SidebarCategoryWithChannels{
|
_, err = ss.Channel().UpdateSidebarCategories(userId2, teamId, []*model.SidebarCategoryWithChannels{
|
||||||
|
{
|
||||||
|
SidebarCategory: channelsCategory2.SidebarCategory,
|
||||||
|
Channels: []string{channel.Id},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
SidebarCategory: favoritesCategory2.SidebarCategory,
|
SidebarCategory: favoritesCategory2.SidebarCategory,
|
||||||
Channels: []string{},
|
Channels: []string{},
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user