From d39abc305d8064d000e5ad0b8acbeb804a86ab77 Mon Sep 17 00:00:00 2001 From: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> Date: Tue, 8 Nov 2022 21:30:14 +0530 Subject: [PATCH] Fix a bug where board didn;t show up in LHS when someone added me on it (#4133) --- server/app/boards.go | 4 ++++ server/app/boards_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/server/app/boards.go b/server/app/boards.go index e7e40f87f..f4e169735 100644 --- a/server/app/boards.go +++ b/server/app/boards.go @@ -519,6 +519,10 @@ func (a *App) AddMemberToBoard(member *model.BoardMember) (*model.BoardMember, e return nil, err } + if err = a.addBoardsToDefaultCategory(member.UserID, board.TeamID, []*model.Board{board}); err != nil { + return nil, err + } + a.blockChangeNotifier.Enqueue(func() error { a.wsAdapter.BroadcastMemberChange(board.TeamID, member.BoardID, member) return nil diff --git a/server/app/boards_test.go b/server/app/boards_test.go index 34e6aef72..5ca96fcf4 100644 --- a/server/app/boards_test.go +++ b/server/app/boards_test.go @@ -27,6 +27,7 @@ func TestAddMemberToBoard(t *testing.T) { } th.Store.EXPECT().GetBoard(boardID).Return(&model.Board{ + ID: "board_id_1", TeamID: "team_id_1", }, nil) @@ -42,6 +43,17 @@ func TestAddMemberToBoard(t *testing.T) { // for WS change broadcast th.Store.EXPECT().GetMembersForBoard(boardID).Return([]*model.BoardMember{}, nil) + th.Store.EXPECT().GetUserCategoryBoards("user_id_1", "team_id_1").Return([]model.CategoryBoards{ + { + Category: model.Category{ + ID: "default_category_id", + Name: "Boards", + Type: "system", + }, + }, + }, nil) + th.Store.EXPECT().AddUpdateCategoryBoard("user_id_1", "default_category_id", "board_id_1").Return(nil) + addedBoardMember, err := th.App.AddMemberToBoard(boardMember) require.NoError(t, err) require.Equal(t, boardID, addedBoardMember.BoardID) @@ -83,6 +95,7 @@ func TestAddMemberToBoard(t *testing.T) { } th.Store.EXPECT().GetBoard(boardID).Return(&model.Board{ + ID: "board_id_1", TeamID: "team_id_1", }, nil) @@ -104,6 +117,17 @@ func TestAddMemberToBoard(t *testing.T) { // for WS change broadcast th.Store.EXPECT().GetMembersForBoard(boardID).Return([]*model.BoardMember{}, nil) + th.Store.EXPECT().GetUserCategoryBoards("user_id_1", "team_id_1").Return([]model.CategoryBoards{ + { + Category: model.Category{ + ID: "default_category_id", + Name: "Boards", + Type: "system", + }, + }, + }, nil) + th.Store.EXPECT().AddUpdateCategoryBoard("user_id_1", "default_category_id", "board_id_1").Return(nil) + addedBoardMember, err := th.App.AddMemberToBoard(boardMember) require.NoError(t, err) require.Equal(t, boardID, addedBoardMember.BoardID)