From 9163e4cd9b332186dc182b534da17c0c19c070a0 Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Wed, 14 Sep 2022 14:59:39 +0200 Subject: [PATCH] Check on GetBoardsForUserAndTeam if the board result list is incomplete and continue if that's the case (#3842) * Check on GetBoardsForUserAndTeam if the board result list is incomplete and continue if that's the case * Remove template filter and correctly check for not founds --- .../store/mattermostauthlayer/mattermostauthlayer.go | 9 +++++++++ server/services/store/sqlstore/board.go | 6 +----- server/services/store/storetests/boards.go | 2 -- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/server/services/store/mattermostauthlayer/mattermostauthlayer.go b/server/services/store/mattermostauthlayer/mattermostauthlayer.go index a3385e034..ce70b3693 100644 --- a/server/services/store/mattermostauthlayer/mattermostauthlayer.go +++ b/server/services/store/mattermostauthlayer/mattermostauthlayer.go @@ -910,6 +910,15 @@ func (s *MattermostAuthLayer) GetBoardsForUserAndTeam(userID, teamID string, inc } boards, err := s.Store.GetBoardsInTeamByIds(boardIDs, teamID) + // ToDo: check if the query is being used appropriately from the + // interface, as we're getting ID sets on request that + // return partial results that seem to be valid + if model.IsErrNotFound(err) { + if boards == nil { + boards = []*model.Board{} + } + return boards, nil + } if err != nil { return nil, err } diff --git a/server/services/store/sqlstore/board.go b/server/services/store/sqlstore/board.go index f8f4471ea..dfd6f91b4 100644 --- a/server/services/store/sqlstore/board.go +++ b/server/services/store/sqlstore/board.go @@ -279,7 +279,6 @@ func (s *SQLStore) getBoardsInTeamByIds(db sq.BaseRunner, boardIDs []string, tea Select(boardFields("b.")...). From(s.tablePrefix + "boards as b"). Where(sq.Eq{"b.team_id": teamID}). - Where(sq.Eq{"b.is_template": false}). Where(sq.Eq{"b.id": boardIDs}) rows, err := query.Query() @@ -299,10 +298,7 @@ func (s *SQLStore) getBoardsInTeamByIds(db sq.BaseRunner, boardIDs []string, tea mlog.Int("len(boards)", len(boards)), mlog.Int("len(boardIDs)", len(boardIDs)), ) - // ToDo: Don't return an error until the query above is fixed to return exactly the same - // number of boards as the ids passed in. - // Wiggin77 thinks the ids list includes templates and this query does not. - // return boards, model.NewErrNotAllFound("board", boardIDs) + return boards, model.NewErrNotAllFound("board", boardIDs) } return boards, nil diff --git a/server/services/store/storetests/boards.go b/server/services/store/storetests/boards.go index 4885c3929..e6c909abf 100644 --- a/server/services/store/storetests/boards.go +++ b/server/services/store/storetests/boards.go @@ -242,7 +242,6 @@ func testGetBoardsInTeamByIds(t *testing.T, store store.Store) { ExpectedError bool ExpectedLen int }{ - /* ToDo: uncomment when getBoardsinTeamsByIds is fixed { Name: "if none of the IDs are found", BoardIDs: []string{"nonexistent-1", "nonexistent-2"}, @@ -255,7 +254,6 @@ func testGetBoardsInTeamByIds(t *testing.T, store store.Store) { ExpectedError: true, ExpectedLen: 1, }, - */ { Name: "if all of the IDs are found", BoardIDs: []string{"board-id-1", "board-id-2"},