Skip to content

Commit

Permalink
rename methods
Browse files Browse the repository at this point in the history
  • Loading branch information
adelinaenache committed May 24, 2024
1 parent f4612b4 commit 0fa2298
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/connections/connections.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ConnectionsController {
@CurrentUser() user: User,
@Param('userId') userId: string,
): Promise<ConnectionDto> {
return this.connectionsService.connectWithUser(user.id, userId);
return this.connectionsService.addConnection(user.id, userId);
}
/**
*
Expand All @@ -65,7 +65,7 @@ export class ConnectionsController {
@CurrentUser() user: User,
@Param('userId') userId: string,
): Promise<ConnectionDto> {
return this.connectionsService.unconnectWithUser(user.id, userId);
return this.connectionsService.removeConnection(user.id, userId);
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/connections/connections.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class ConnectionsService {
}

// transforms an user from db to a Connection DTO
private transformUserConnection(
private convertConnectionToDto(
user: User & { _count: { followings: number; reviewsReceived: number } } & {
followers?: { id: number; followerId: string; followingId: string }[];
},
Expand Down Expand Up @@ -67,7 +67,7 @@ export class ConnectionsService {
throw new NotFoundException(`User with ${connectionId} not found`);
}

return this.transformUserConnection(user);
return this.convertConnectionToDto(user);
}

async getUserConnections(userId: User['id']) {
Expand All @@ -82,10 +82,10 @@ export class ConnectionsService {
},
});

return connections.map((c) => this.transformUserConnection(c.following));
return connections.map((c) => this.convertConnectionToDto(c.following));
}

async connectWithUser(currentUserId: User['id'], userId: User['id']) {
async addConnection(currentUserId: User['id'], userId: User['id']) {
await this.prisma.connection.upsert({
where: {
followerId_followingId: {
Expand All @@ -103,7 +103,7 @@ export class ConnectionsService {
return this.getConnection(userId, currentUserId);
}

async unconnectWithUser(currentUserId: User['id'], userId: User['id']) {
async removeConnection(currentUserId: User['id'], userId: User['id']) {
await this.prisma.connection.delete({
where: {
followerId_followingId: {
Expand All @@ -129,7 +129,7 @@ export class ConnectionsService {
include: this.includeWithUserConnection(userId),
});

return users.map((u) => this.transformUserConnection(u));
return users.map((u) => this.convertConnectionToDto(u));
}

async searchUserByExternalProfile(profileUrlBase64: string) {
Expand All @@ -143,7 +143,7 @@ export class ConnectionsService {
user: { include: this.includeWithUserConnection() },
},
});
if (socialAccount) return this.transformUserConnection(socialAccount.user);
if (socialAccount) return this.convertConnectionToDto(socialAccount.user);

// Fetch the profile details
const profileData = await new ProfileFetcherDelegator(
Expand Down Expand Up @@ -172,6 +172,6 @@ export class ConnectionsService {
},
}),
]);
return this.transformUserConnection(newUser);
return this.convertConnectionToDto(newUser);
}
}

0 comments on commit 0fa2298

Please sign in to comment.