Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/common/logger/logger.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Global, Module } from '@nestjs/common';
import { LoggerModule as PinoLoggerModule } from 'nestjs-pino';
import { Request } from 'express';
import { AppLoggerService } from './pino-logger.service';
import { v4 } from 'uuid';

const isDevelopment = process.env.NODE_ENV === 'development';

Expand All @@ -11,6 +12,7 @@ const isDevelopment = process.env.NODE_ENV === 'development';
PinoLoggerModule.forRoot({
pinoHttp: {
level: isDevelopment ? 'debug' : 'info',
genReqId: (req: Request) => req.headers['x-request-id'] ?? v4(),
transport: isDevelopment
? {
target: 'pino-pretty',
Expand Down
12 changes: 6 additions & 6 deletions src/modules/call/webhooks/jitsi/jitsi-webhook.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ export class JitsiWebhookController {
break;

default:
this.logger.log(
`Ignoring unhandled event type: ${payload.eventType}`,
this.logger.warn(
{
eventType: payload.eventType,
},
'Ignoring unhandled event type',
);
break;
}

return { success: true };
} catch (error: unknown) {
if (error instanceof Error) {
this.logger.error(
`Error processing webhook event: ${error.message}`,
error.stack,
);
this.logger.error({ error }, 'Error processing webhook event');
}
throw new BadRequestException(`Error processing webhook event`);
}
Expand Down
17 changes: 7 additions & 10 deletions src/modules/call/webhooks/jitsi/jitsi-webhook.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ import { JitsiParticipantLeftWebHookPayload } from './interfaces/JitsiParticipan
export class JitsiWebhookService {
private readonly logger = new Logger(JitsiWebhookService.name);
private readonly webhookSecret: string | undefined;
private readonly participantLeftEnabled: boolean;

constructor(
private readonly configService: ConfigService,
private readonly roomService: RoomService,
) {
this.webhookSecret = this.configService.get<string>('jitsiWebhook.secret');
this.participantLeftEnabled = this.configService.get<boolean>(
'jitsiWebhook.events.participantLeft',
true,
);
}

/**
Expand All @@ -31,7 +26,8 @@ export class JitsiWebhookService {
): Promise<void> {
try {
this.logger.log(
`Handling PARTICIPANT_LEFT event for participant: ${payload.data.id}`,
{ idempotencyKey: payload.idempotencyKey },
'Handling PARTICIPANT_LEFT event',
);

const roomId = this.extractRoomId(payload.fqn);
Expand All @@ -51,7 +47,7 @@ export class JitsiWebhookService {
const room = await this.roomService.getRoomByRoomId(roomId);

if (!room) {
this.logger.warn(`Room with ID ${roomId} not found`);
this.logger.warn({ roomId }, 'Room not found');
return;
}

Expand All @@ -61,10 +57,11 @@ export class JitsiWebhookService {
await this.roomService.removeUserFromRoom(participantId, room);

this.logger.log(
`Successfully processed PARTICIPANT_LEFT event for participant ${participantId} in room ${roomId}`,
{ participantId, roomId },
'Successfully processed PARTICIPANT_LEFT event',
);
} catch (error) {
this.logger.error('Error handling PARTICIPANT_LEFT event', error);
} catch (error: unknown) {
this.logger.error({ error }, 'Error handling PARTICIPANT_LEFT event');
throw error;
}
}
Expand Down
Loading