set update_at on bookmarks return when changing sort order (#28807)
* set update_at on bookmarks return when changing sort order * update bookmarks sort order test
Этот коммит содержится в:
@@ -963,8 +963,7 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("a websockets event should be fired as part of editing a bookmark's sort order", func(t *testing.T) {
|
t.Run("a websockets event should be fired as part of editing a bookmark's sort order", func(t *testing.T) {
|
||||||
t.Skip("MM-60499")
|
now := model.GetMillis()
|
||||||
|
|
||||||
webSocketClient, err := th.CreateWebSocketClient()
|
webSocketClient, err := th.CreateWebSocketClient()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
webSocketClient.Listen()
|
webSocketClient.Listen()
|
||||||
@@ -978,6 +977,14 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
|||||||
Emoji: ":smile:",
|
Emoji: ":smile:",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bookmark2 := &model.ChannelBookmark{
|
||||||
|
ChannelId: th.BasicChannel.Id,
|
||||||
|
DisplayName: "Link bookmark test 2",
|
||||||
|
LinkUrl: "https://mattermost.com",
|
||||||
|
Type: model.ChannelBookmarkLink,
|
||||||
|
Emoji: ":smile:",
|
||||||
|
}
|
||||||
|
|
||||||
// set the user for the session
|
// set the user for the session
|
||||||
originalSessionUserId := th.Context.Session().UserId
|
originalSessionUserId := th.Context.Session().UserId
|
||||||
th.Context.Session().UserId = th.BasicUser.Id
|
th.Context.Session().UserId = th.BasicUser.Id
|
||||||
@@ -987,6 +994,10 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
|||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
require.NotNil(t, cb)
|
require.NotNil(t, cb)
|
||||||
|
|
||||||
|
cb, appErr = th.App.CreateChannelBookmark(th.Context, bookmark2, "")
|
||||||
|
require.Nil(t, appErr)
|
||||||
|
require.NotNil(t, cb)
|
||||||
|
|
||||||
bookmarks, resp, err := th.Client.UpdateChannelBookmarkSortOrder(context.Background(), th.BasicChannel.Id, cb.Id, 0)
|
bookmarks, resp, err := th.Client.UpdateChannelBookmarkSortOrder(context.Background(), th.BasicChannel.Id, cb.Id, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
CheckOKStatus(t, resp)
|
CheckOKStatus(t, resp)
|
||||||
@@ -1001,6 +1012,10 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
|||||||
if event.EventType() == model.WebsocketEventChannelBookmarkSorted {
|
if event.EventType() == model.WebsocketEventChannelBookmarkSorted {
|
||||||
err := json.Unmarshal([]byte(event.GetData()["bookmarks"].(string)), &bl)
|
err := json.Unmarshal([]byte(event.GetData()["bookmarks"].(string)), &bl)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
for _, b := range bl {
|
||||||
|
require.Greater(t, b.UpdateAt, now)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case <-timeout:
|
case <-timeout:
|
||||||
waiting = false
|
waiting = false
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ func (s *SqlChannelBookmarkStore) UpdateSortOrder(bookmarkId, channelId string,
|
|||||||
ids := []string{}
|
ids := []string{}
|
||||||
for index, b := range bookmarks {
|
for index, b := range bookmarks {
|
||||||
b.SortOrder = int64(index)
|
b.SortOrder = int64(index)
|
||||||
|
b.UpdateAt = now
|
||||||
caseStmt = caseStmt.When(sq.Eq{"Id": b.Id}, strconv.FormatInt(int64(index), 10))
|
caseStmt = caseStmt.When(sq.Eq{"Id": b.Id}, strconv.FormatInt(int64(index), 10))
|
||||||
ids = append(ids, b.Id)
|
ids = append(ids, b.Id)
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user