feat(kbshare): enhance knowledge base share listing with tenant ownership

This commit is contained in:
wizardchen
2026-02-06 17:54:40 +08:00
committed by lyingbug
parent f065b1df45
commit 4f44c12c41
3 changed files with 25 additions and 4 deletions
+9 -2
View File
@@ -174,8 +174,15 @@ func (s *kbShareService) RemoveShare(ctx context.Context, shareID string, userID
return ErrSharePermissionDenied
}
// ListSharesByKnowledgeBase lists all shares for a knowledge base
func (s *kbShareService) ListSharesByKnowledgeBase(ctx context.Context, kbID string) ([]*types.KnowledgeBaseShare, error) {
// ListSharesByKnowledgeBase lists shares for a knowledge base; caller's tenant must own the KB.
func (s *kbShareService) ListSharesByKnowledgeBase(ctx context.Context, kbID string, tenantID uint64) ([]*types.KnowledgeBaseShare, error) {
kb, err := s.kbRepo.GetKnowledgeBaseByID(ctx, kbID)
if err != nil {
return nil, ErrKBNotFound
}
if kb.TenantID != tenantID {
return nil, ErrNotKBOwner
}
return s.shareRepo.ListByKnowledgeBase(ctx, kbID)
}