File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -603,7 +603,17 @@ export class CardsetUseCase {
603603
604604 async findCardsFromYjs (
605605 cardSetId : number ,
606+ userId : number ,
606607 ) : Promise < { id : string ; question : string ; answer : string } [ ] > {
608+ const cardset = await this . cardsetRepository . findById ( cardSetId ) ;
609+ if ( ! cardset ) throw new BusinessException ( ErrorCode . CARDSET_NOT_FOUND ) ;
610+ if ( cardset . visibility !== Visibility . PUBLIC ) {
611+ const inGroup =
612+ ! isNaN ( userId ) &&
613+ ( await this . groupGrpcClient . isUserInGroup ( cardset . groupId , userId ) ) ;
614+ if ( ! inGroup )
615+ throw new BusinessException ( ErrorCode . CARDSET_ACCESS_DENIED ) ;
616+ }
607617 const cards = await this . collaborationUseCase . getCardsFromDB ( cardSetId ) ;
608618 this . logger . log ( `[cardset:${ cardSetId } ] cards: ${ JSON . stringify ( cards ) } ` ) ;
609619 return cards ;
Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ export class CardsetController {
188188 ) : Promise < ApiResponse < YjsCardResponse [ ] > > {
189189 const cards = await this . cardsetUseCase . findCardsFromYjs (
190190 parseInt ( cardsetId ) ,
191+ parseInt ( _userId ) ,
191192 ) ;
192193 return ApiResponse . success ( cards . map ( ( c ) => YjsCardResponse . from ( c ) ) ) ;
193194 }
You can’t perform that action at this time.
0 commit comments