Skip to content

Commit 43f4a93

Browse files
feat: decouple share certificate codebase (#1071)
Signed-off-by: bhavanakarwade <[email protected]>
1 parent 975c9e2 commit 43f4a93

File tree

19 files changed

+14
-1074
lines changed

19 files changed

+14
-1074
lines changed

apps/api-gateway/src/user/dto/share-certificate.dto.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

apps/api-gateway/src/user/user.controller.ts

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import { OrgRolesGuard } from '../authz/guards/org-roles.guard';
4949
import { OrgRoles } from 'libs/org-roles/enums';
5050
import { AwsService } from '@credebl/aws/aws.service';
5151
import { PaginationDto } from '@credebl/common/dtos/pagination.dto';
52-
import { CreateCertificateDto } from './dto/share-certificate.dto';
5352
import { UserAccessGuard } from '../authz/guards/user-access-guard';
5453

5554
@UseFilters(CustomExceptionFilter)
@@ -266,23 +265,6 @@ export class UserController {
266265

267266
return res.status(HttpStatus.OK).json(finalResponse);
268267
}
269-
/**
270-
* @param credentialId
271-
* @returns User credentials
272-
*/
273-
@Get('/user-credentials/:credentialId')
274-
@ApiOperation({ summary: 'Get user credentials by Id', description: 'Get user credentials by Id' })
275-
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
276-
async getUserCredentialsById(@Param('credentialId') credentialId: string, @Res() res: Response): Promise<Response> {
277-
const getUserCrdentialsById = await this.userService.getUserCredentialsById(credentialId);
278-
279-
const finalResponse: IResponse = {
280-
statusCode: HttpStatus.OK,
281-
message: ResponseMessages.user.success.userCredentials,
282-
data: getUserCrdentialsById
283-
};
284-
return res.status(HttpStatus.OK).json(finalResponse);
285-
}
286268

287269
/**
288270
*
@@ -311,34 +293,7 @@ export class UserController {
311293
};
312294
return res.status(HttpStatus.CREATED).json(finalResponse);
313295
}
314-
/**
315-
* @Body shareUserCredentials
316-
* @returns User certificate URL
317-
*/
318-
@Post('/certificate')
319-
@ApiOperation({
320-
summary: 'Share user certificate',
321-
description: 'Share user certificate'
322-
})
323-
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
324-
async shareUserCertificate(
325-
@Body() shareUserCredentials: CreateCertificateDto,
326-
@Res() res: Response
327-
): Promise<Response> {
328-
const schemaIdParts = shareUserCredentials.schemaId.split(':');
329-
// eslint-disable-next-line prefer-destructuring
330-
const title = schemaIdParts[2];
331-
332-
const imageBuffer = await this.userService.shareUserCertificate(shareUserCredentials);
333-
const finalResponse: IResponse = {
334-
statusCode: HttpStatus.CREATED,
335-
message: ResponseMessages.user.success.shareUserCertificate || ResponseMessages.user.success.degreeCertificate,
336-
label: title,
337-
data: imageBuffer
338-
};
339-
return res.status(HttpStatus.CREATED).json(finalResponse);
340-
}
341-
296+
342297
/**
343298
* @Body updateUserProfileDto
344299
* @returns User details

apps/api-gateway/src/user/user.service.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { IUsersActivity } from 'libs/user-activity/interface';
1111
import { IUserInvitations } from '@credebl/common/interfaces/user.interface';
1212
import { user } from '@prisma/client';
1313
import { PaginationDto } from '@credebl/common/dtos/pagination.dto';
14-
import { CreateCertificateDto } from './dto/share-certificate.dto';
1514

1615
@Injectable()
1716
export class UserService extends BaseService {
@@ -29,12 +28,6 @@ export class UserService extends BaseService {
2928
return this.sendNatsMessage(this.serviceProxy, 'get-user-public-profile', payload);
3029
}
3130

32-
33-
async getUserCredentialsById(credentialId: string): Promise<object> {
34-
const payload = { credentialId };
35-
return this.sendNatsMessage(this.serviceProxy, 'get-user-credentials-by-id', payload);
36-
}
37-
3831
async updateUserProfile(updateUserProfileDto: UpdateUserProfileDto): Promise<user> {
3932
const payload = { updateUserProfileDto };
4033
return this.sendNatsMessage(this.serviceProxy, 'update-user-profile', payload);
@@ -64,12 +57,6 @@ export class UserService extends BaseService {
6457
return this.sendNatsMessage(this.serviceProxy, 'accept-reject-invitations', payload);
6558
}
6659

67-
async shareUserCertificate(
68-
shareUserCredentials: CreateCertificateDto
69-
): Promise<Buffer> {
70-
return this.sendNatsMessage(this.serviceProxy, 'share-user-certificate', shareUserCredentials);
71-
}
72-
7360
async get(
7461
paginationDto:PaginationDto
7562
): Promise<object> {

apps/organization/src/organization.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ export class OrganizationService {
470470
try {
471471
const updatedOrglogo = orgLogo.split(',')[1];
472472
const imgData = Buffer.from(updatedOrglogo, 'base64');
473-
const logoUrl = await this.awsService.uploadUserCertificate(
473+
const logoUrl = await this.awsService.uploadFileToS3Bucket(
474474
imgData,
475475
'png',
476476
'orgLogo',

apps/user/interfaces/user.interface.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,6 @@ export interface ICheckUserDetails {
106106
isFidoVerified?: boolean;
107107
isRegistrationCompleted?: boolean;
108108
}
109-
export interface IUserCredentials {
110-
id: string;
111-
imageUrl?: string;
112-
credentialId?: string;
113-
createDateTime: Date;
114-
lastChangedDateTime: Date;
115-
deletedAt: Date;
116-
}
117109

118110
export interface IOrgUsers {
119111
totalPages: number,

apps/user/repositories/user.repository.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/* eslint-disable prefer-destructuring */
22

3-
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
3+
import { Injectable, Logger, NotFoundException, InternalServerErrorException } from '@nestjs/common';
44
import {
55
IOrgUsers,
66
PlatformSettings,
77
IShareUserCertificate,
88
UpdateUserProfile,
9-
IUserCredentials,
109
ISendVerificationEmail,
1110
IUsersProfile,
1211
IUserInformation,
@@ -16,7 +15,6 @@ import {
1615
UserRoleMapping,
1716
UserRoleDetails
1817
} from '../interfaces/user.interface';
19-
import { InternalServerErrorException } from '@nestjs/common';
2018
import { PrismaService } from '@credebl/prisma-service';
2119
// eslint-disable-next-line camelcase
2220
import { RecordType, schema, token, user, user_org_roles } from '@prisma/client';
@@ -118,19 +116,6 @@ export class UserRepository {
118116
return this.findUser(queryOptions);
119117
}
120118

121-
/**
122-
*
123-
* @param id
124-
* @returns User profile data
125-
*/
126-
async getUserCredentialsById(credentialId: string): Promise<IUserCredentials> {
127-
return this.prisma.user_credentials.findUnique({
128-
where: {
129-
credentialId
130-
}
131-
});
132-
}
133-
134119
/**
135120
*
136121
* @param id
@@ -561,20 +546,6 @@ export class UserRepository {
561546
}
562547
}
563548

564-
async saveCertificateImageUrl(imageUrl: string, credentialId: string): Promise<unknown> {
565-
try {
566-
const saveImageUrl = await this.prisma.user_credentials.create({
567-
data: {
568-
imageUrl,
569-
credentialId
570-
}
571-
});
572-
return saveImageUrl;
573-
} catch (error) {
574-
throw new Error(`Error saving certificate image URL: ${error.message}`);
575-
}
576-
}
577-
578549
async checkUniqueUserExist(email: string): Promise<user> {
579550
try {
580551
return this.prisma.user.findUnique({

apps/user/src/user.controller.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IOrgUsers, Payload, ICheckUserDetails, PlatformSettings, IShareUserCertificate, UpdateUserProfile, IUsersProfile, IUserInformation, IUserSignIn, IUserCredentials, IUserResetPassword, IUserDeletedActivity, UserKeycloakId, IUserForgotPassword} from '../interfaces/user.interface';
1+
import { IOrgUsers, Payload, ICheckUserDetails, PlatformSettings, UpdateUserProfile, IUsersProfile, IUserInformation, IUserSignIn, IUserResetPassword, IUserDeletedActivity, UserKeycloakId, IUserForgotPassword} from '../interfaces/user.interface';
22
import { AcceptRejectInvitationDto } from '../dtos/accept-reject-invitation.dto';
33
import { Controller } from '@nestjs/common';
44
import { MessagePattern } from '@nestjs/microservices';
@@ -102,15 +102,6 @@ export class UserController {
102102
return this.userService.findUserByUserId(id);
103103
}
104104

105-
/**
106-
* @param credentialId
107-
* @returns User credentials
108-
*/
109-
@MessagePattern({ cmd: 'get-user-credentials-by-id' })
110-
async getUserCredentialsById(payload: { credentialId }): Promise<IUserCredentials> {
111-
return this.userService.getUserCredentialsById(payload);
112-
}
113-
114105
/**
115106
* @returns Organization invitation data
116107
*/
@@ -132,17 +123,6 @@ export class UserController {
132123
return this.userService.acceptRejectInvitations(payload.acceptRejectInvitation, payload.userId);
133124
}
134125

135-
/**
136-
* @param payload
137-
* @returns User certificate URL
138-
*/
139-
@MessagePattern({ cmd: 'share-user-certificate' })
140-
async shareUserCertificate(
141-
shareUserCredentials: IShareUserCertificate
142-
): Promise<string> {
143-
return this.userService.shareUserCertificate(shareUserCredentials);
144-
}
145-
146126
/**
147127
*
148128
* @param payload

0 commit comments

Comments
 (0)