From 73214a1b3bbf977247bf5feed1fdfe6aa0e76e2e Mon Sep 17 00:00:00 2001 From: Sina Iman Date: Thu, 27 Jun 2024 18:40:18 +0200 Subject: [PATCH] add support to claim all optional attestations --- desci-server/src/controllers/attestations/claims.ts | 2 +- desci-server/src/routes/v1/attestations/index.ts | 4 ++-- desci-server/src/services/Attestation.ts | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/desci-server/src/controllers/attestations/claims.ts b/desci-server/src/controllers/attestations/claims.ts index d499fc356..0a07dac16 100644 --- a/desci-server/src/controllers/attestations/claims.ts +++ b/desci-server/src/controllers/attestations/claims.ts @@ -129,7 +129,7 @@ export const claimEntryRequirements = async (req: Request, res: Response, _next: logger.info({ communityId, body: req.body }, 'claimEntryRequirements'); const uuid = ensureUuidEndsWithDot(nodeUuid); - const entryAttestations = await attestationService.getCommunityEntryAttestations(communityId); + const entryAttestations = await attestationService.getAllCommunityEntryAttestations(communityId); logger.info({ entryAttestations }); const claimables = (await asyncMap(entryAttestations, async (attestation) => { diff --git a/desci-server/src/routes/v1/attestations/index.ts b/desci-server/src/routes/v1/attestations/index.ts index cfefa0b0d..dc27c02dc 100644 --- a/desci-server/src/routes/v1/attestations/index.ts +++ b/desci-server/src/routes/v1/attestations/index.ts @@ -43,8 +43,8 @@ import { const router = Router(); -router.get('/suggestions/all', [ensureUser], asyncHander(getAllRecommendations)); -router.get('/suggestions/protected', [ensureUser], asyncHander(getValidatedRecommendations)); +router.get('/suggestions/all', [], asyncHander(getAllRecommendations)); +router.get('/suggestions/protected', [], asyncHander(getValidatedRecommendations)); router.get( '/claims/:communityId/:dpid', [ensureUser, validate(showCommunityClaimsSchema)], diff --git a/desci-server/src/services/Attestation.ts b/desci-server/src/services/Attestation.ts index 63c53a82c..489d45616 100644 --- a/desci-server/src/services/Attestation.ts +++ b/desci-server/src/services/Attestation.ts @@ -290,6 +290,12 @@ export class AttestationService { return prisma.communityEntryAttestation.findMany({ where: { desciCommunityId: communityId, required: true } }); } + async getAllCommunityEntryAttestations(communityId: number) { + const community = await communityService.findCommunityById(communityId); + if (!community) throw new CommunityNotFoundError(); + return prisma.communityEntryAttestation.findMany({ where: { desciCommunityId: communityId } }); + } + async claimAttestation({ attestationId, attestationVersion,