Skip to content

Commit

Permalink
Merge pull request #110 from Amruth-Vamshi/feature/WA-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
ChakshuGautam authored Dec 20, 2024
2 parents f8ec7c0 + 6aeab5c commit d3348a0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/api/api.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class ApiController {
@Query() params: SendOtpDto,
@Headers('x-application-id') applicationId?,
): Promise<any> {
const startTime = Date.now();
const startTime = ((performance.timeOrigin + performance.now()) * 1000);

let status: any,
isWhatsApp = false,
Expand Down Expand Up @@ -136,7 +136,7 @@ export class ApiController {
{
botId: params.botId,
orgId: params.orgId,
timeTaken: Date.now() - startTime,
timeTaken: ((performance.timeOrigin + performance.now()) * 1000) - startTime,
createdAt: Math.floor(new Date().getTime() / 1000),
phoneNumber: params.phone,
eventLog: `Response from OTP provider - ${status.providerSuccessResponse}`,
Expand Down Expand Up @@ -430,6 +430,7 @@ export class ApiController {
@Headers('authorization') authHeader,
@Headers('ADMIN-API-KEY') adminApiKey,
): Promise<any> {
const startTime = ((performance.timeOrigin + performance.now()) * 1000);
if (adminApiKey != this.configService.get('ADMIN_API_KEY')) {
const response: SignupResponse = new SignupResponse().init(uuidv4());
response.responseCode = ResponseCode.FAILURE;
Expand All @@ -438,7 +439,25 @@ export class ApiController {
response.params.status = ResponseStatus.failure;
return response;
}
return await this.apiService.loginWithUniqueId(user, authHeader);
let response = await this.apiService.loginWithUniqueId(user, authHeader);
if (this.configService.get('TELEMETRY_INTERNAL_BASE_URL')) {
this.telemetryService.sendEvent(
{
botId: user.botId,
orgId: null,
timeTaken: ((performance.timeOrigin + performance.now()) * 1000) - startTime,
createdAt: Math.floor(new Date().getTime() / 1000),
userId: response.result.data.user.id,
eventLog: `Status from Fusionauth - ${response.responseCode}`,
fingerprint: user.loginId
},
'E119',
'Guest Login',
'GuestLogin',
'PWA'
);
}
return response;
}

@Post('jwt/verify')
Expand Down
4 changes: 4 additions & 0 deletions src/api/dto/login.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ export class LoginWithUniqueIdDto {
@IsUUID()
@IsNotEmpty()
applicationId: string;

@IsOptional()
@IsUUID()
botId: string;
}

0 comments on commit d3348a0

Please sign in to comment.