(ctx context.Context, projectID string, worksheetID string, loadFull bool)
| 382 | } |
| 383 | |
| 384 | func (s *WorksheetService) findWorksheet(ctx context.Context, projectID string, worksheetID string, loadFull bool) (*store.WorkSheetMessage, error) { |
| 385 | user, ok := GetUserFromContext(ctx) |
| 386 | if !ok { |
| 387 | return nil, connect.NewError(connect.CodeInternal, errors.Errorf("user not found")) |
| 388 | } |
| 389 | worksheet, err := s.store.GetWorkSheet(ctx, &store.FindWorkSheetMessage{ |
| 390 | ProjectIDs: []string{projectID}, |
| 391 | ResourceID: &worksheetID, |
| 392 | LoadFull: loadFull, |
| 393 | PrincipalEmail: user.Email, |
| 394 | }) |
| 395 | if err != nil { |
| 396 | return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get worksheet: %v", err)) |
| 397 | } |
| 398 | if worksheet == nil { |
| 399 | return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("cannot find the worksheet")) |
| 400 | } |
| 401 | return worksheet, nil |
| 402 | } |
| 403 | |
| 404 | // canWriteWorksheet check if the principal can write the worksheet. |
| 405 | // worksheet is writable when the user has bb.worksheets.manage permission on the workspace, or. |
no test coverage detected