diff --git a/src/database/migrations/1651143902595-create_nfts_table.ts b/src/database/migrations/1651143902595-create_nfts_table.ts index 2dfe294..31a9d8b 100644 --- a/src/database/migrations/1651143902595-create_nfts_table.ts +++ b/src/database/migrations/1651143902595-create_nfts_table.ts @@ -14,13 +14,14 @@ export class createNftsTable1651143902595 implements MigrationInterface { "ownerId" int8, "creatorAddress" varchar NOT NULL, "creatorId" int8, + "creatorUsername" varchar, "ownerUsername" varchar, "name" varchar NOT NULL, "description" varchar NOT NULL, "fileSize" float4 DEFAULT 0.0, "fileType" varchar, "listed" bool DEFAULT false, - "listedOnchain" bool DEFAULT false, + "listedOnChain" bool DEFAULT false, "verified" bool DEFAULT false, "isVideo" bool DEFAULT false, "image" varchar, diff --git a/src/modules/nfts-drops/nfts-drops.controller.ts b/src/modules/nfts-drops/nfts-drops.controller.ts index 7480d74..13ec259 100644 --- a/src/modules/nfts-drops/nfts-drops.controller.ts +++ b/src/modules/nfts-drops/nfts-drops.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Post, Body } from '@nestjs/common'; +import { Controller, Post, Body, Get, Param } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { NftsDropsService } from './nfts-drops.service'; import { NftsService } from '../nfts/nfts.service'; @@ -9,6 +9,14 @@ import { CreateDropDto } from './nfts-drops.dto'; export class NftsDropsController { constructor(private readonly dropService: NftsDropsService, private readonly nftService: NftsService) {} + @Get('/:dropID') + async findOneByDropId(@Param('dropID') dropID: string) { + const drop = await this.dropService.findOneByDropID(dropID); + return { + drop, + }; + } + @Post('/') async createDrop(@Body() dropData: CreateDropDto) { const drop = await this.dropService.save(dropData); diff --git a/src/modules/nfts-drops/nfts-drops.service.ts b/src/modules/nfts-drops/nfts-drops.service.ts index a857320..cb4767c 100644 --- a/src/modules/nfts-drops/nfts-drops.service.ts +++ b/src/modules/nfts-drops/nfts-drops.service.ts @@ -33,7 +33,7 @@ export class NftsDropsService { findOneByDropID(dropID: string): Promise { return this.dropRepository.findOne({ - relations: ['creator'], + relations: ['creator', 'nfts'], where: { dropID }, }); } diff --git a/src/modules/nfts/nfts.entity.ts b/src/modules/nfts/nfts.entity.ts index 7e8d86e..9b96362 100644 --- a/src/modules/nfts/nfts.entity.ts +++ b/src/modules/nfts/nfts.entity.ts @@ -100,6 +100,9 @@ export class Nft { @JoinColumn() owner: User; + @Column({ nullable: true, type: 'int8', default: null }) + dropId: number; + @ManyToOne(() => NftDrop, (drop: NftDrop) => drop.nfts) @JoinColumn() drop: NftDrop; diff --git a/src/modules/users/users.controller.ts b/src/modules/users/users.controller.ts index 7ba47ab..50e3a4a 100644 --- a/src/modules/users/users.controller.ts +++ b/src/modules/users/users.controller.ts @@ -1,14 +1,15 @@ import { Controller, Get, Param, Put, Body, BadRequestException, CacheTTL, UseGuards } from '@nestjs/common'; - import { ApiTags } from '@nestjs/swagger'; +import { WalletSignatureGuard } from 'src/guards/walletSignature.guard'; import { isValidAddress } from 'src/utils/Utils'; import { NftsService } from '../nfts/nfts.service'; import { UsersService } from './users.service'; import { UserUpdateProfileDto } from './users.dto'; import { Web3Helper } from '../../utils/web3Helper'; -import { WalletSignatureGuard } from '../../guards/walletSignature.guard'; + @ApiTags('users') @Controller('users') +@UseGuards(WalletSignatureGuard) export class UsersController { constructor(private readonly userService: UsersService, private readonly nftService: NftsService) {} @@ -17,6 +18,12 @@ export class UsersController { async updateProfile(@Body() userData: UserUpdateProfileDto) { const checksumAddress = Web3Helper.getAddressChecksum(userData.walletAddress); + const foundUser = await this.userService.findByAddress(checksumAddress); + + if (userData.username && foundUser?.username?.toLocaleLowerCase() !== userData?.username?.toLocaleLowerCase()) { + const newFoundUser = await this.userService.findByUsername(userData.username); + + const foundUser = await this.userService.findByAddress(checksumAddress); if (userData.username && foundUser?.username?.toLocaleLowerCase() !== userData?.username?.toLocaleLowerCase()) { @@ -84,4 +91,4 @@ export class UsersController { user, }; } -} +} \ No newline at end of file diff --git a/src/modules/users/users.dto.ts b/src/modules/users/users.dto.ts index 9bd37bf..669a530 100644 --- a/src/modules/users/users.dto.ts +++ b/src/modules/users/users.dto.ts @@ -1,10 +1,13 @@ -import { IsString, IsOptional } from 'class-validator'; +import { IsString, IsOptional, IsNumber } from 'class-validator'; export class UserDto { readonly walletAddress: string; } export class UserUpdateProfileDto { + @IsNumber() + readonly id: number; + @IsString() readonly walletAddress: string; @@ -36,22 +39,6 @@ export class UserUpdateProfileDto { @IsOptional() readonly coverThumbnailUrl?: string; - @IsString() - @IsOptional() - readonly socialUrl?: string; - - @IsString() - @IsOptional() - readonly twitterUrl?: string; - - @IsString() - @IsOptional() - readonly instagramUrl?: string; - - @IsString() - @IsOptional() - readonly facebookUrl?: string; - @IsString() signature?: string; }