mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
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
This commit is contained in:
parent
48cde8c0bf
commit
f8f998bfcb
2 changed files with 18 additions and 2 deletions
|
|
@ -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.Skip("MM-60499")
|
||||
|
||||
now := model.GetMillis()
|
||||
webSocketClient, err := th.CreateWebSocketClient()
|
||||
require.NoError(t, err)
|
||||
webSocketClient.Listen()
|
||||
|
|
@ -978,6 +977,14 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
|||
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
|
||||
originalSessionUserId := th.Context.Session().UserId
|
||||
th.Context.Session().UserId = th.BasicUser.Id
|
||||
|
|
@ -987,6 +994,10 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
|||
require.Nil(t, appErr)
|
||||
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)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
|
|
@ -1001,6 +1012,10 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
|||
if event.EventType() == model.WebsocketEventChannelBookmarkSorted {
|
||||
err := json.Unmarshal([]byte(event.GetData()["bookmarks"].(string)), &bl)
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, b := range bl {
|
||||
require.Greater(t, b.UpdateAt, now)
|
||||
}
|
||||
}
|
||||
case <-timeout:
|
||||
waiting = false
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ func (s *SqlChannelBookmarkStore) UpdateSortOrder(bookmarkId, channelId string,
|
|||
ids := []string{}
|
||||
for index, b := range bookmarks {
|
||||
b.SortOrder = int64(index)
|
||||
b.UpdateAt = now
|
||||
caseStmt = caseStmt.When(sq.Eq{"Id": b.Id}, strconv.FormatInt(int64(index), 10))
|
||||
ids = append(ids, b.Id)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue