File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -207,3 +207,15 @@ export const exampleRankingDto = {
207207 ] ,
208208 } ,
209209} ;
210+
211+ export class AttestationDto {
212+ @IsDefined ( )
213+ @Validate ( IsPositiveOrNegativeOneConstraint )
214+ @ApiProperty ( )
215+ collectionId : number ;
216+
217+ @IsString ( )
218+ @IsDefined ( )
219+ @ApiProperty ( )
220+ attestationId : string ;
221+ }
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import { AuthedReq } from 'src/utils/types/AuthedReq.type';
2424import { PairsResult } from './dto/pairsResult' ;
2525import { sortProjectId } from 'src/utils' ;
2626import {
27+ AttestationDto ,
2728 BudgetDto ,
2829 ConnectFarcasterDto ,
2930 ConnectWorldIdDto ,
@@ -1084,6 +1085,46 @@ export class FlowController {
10841085 else return { ...result , budget : budgetRes ?. budget } ;
10851086 }
10861087
1088+ @UseGuards ( AuthGuard )
1089+ @ApiOperation ( {
1090+ summary :
1091+ 'Notifies the server that the user has done an attestation for a collection' ,
1092+ } )
1093+ @Post ( '/report-attest' )
1094+ async reportAttestations (
1095+ @Req ( ) { userId } : AuthedReq ,
1096+ @Body ( ) { collectionId, attestationId } : AttestationDto ,
1097+ ) {
1098+ // collectionId = -1 is for the budget attestation
1099+ const isFinished =
1100+ collectionId > 0
1101+ ? await this . flowService . isCollectionFinished ( userId , collectionId )
1102+ : true ;
1103+
1104+ if ( ! isFinished )
1105+ throw new ForbiddenException (
1106+ 'You can not attest a collection which is yet to be finished' ,
1107+ ) ;
1108+
1109+ await this . prismaService . userAttestation . upsert ( {
1110+ where : {
1111+ userId_collectionId : {
1112+ userId : userId ,
1113+ collectionId : collectionId ,
1114+ } ,
1115+ } ,
1116+ create : {
1117+ userId : userId ,
1118+ collectionId : collectionId ,
1119+ attestationId,
1120+ } ,
1121+ update : {
1122+ attestationId,
1123+ } ,
1124+ } ) ;
1125+ return 'Success' ;
1126+ }
1127+
10871128 // @UseGuards (AuthGuard)
10881129 // @Post ('/reset')
10891130 // async resetVotes(@Req() { userId }: AuthedReq, @Body('cid') cid: number) {
You can’t perform that action at this time.
0 commit comments