Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
10 changes: 7 additions & 3 deletions src/modules/call/call.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,14 @@ export class CallController {
@ApiInternalServerErrorResponse({ description: 'Internal server error' })
leaveCall(
@Param('id') roomId: string,
@User() user: UserTokenData['payload'],
@Body() leaveCallDto?: LeaveCallDto,
): Promise<void> {
const { uuid } = user || {};
return this.callUseCase.leaveCall(roomId, uuid || leaveCallDto?.userId);
if (leaveCallDto?.userId) {
this.logger.warn(
`Attempt to leave call without user ID: ${leaveCallDto}`,
);
throw new BadRequestException('The user id is needed to leave the call');
}
Comment thread
jzunigax2 marked this conversation as resolved.
Outdated
return this.callUseCase.leaveCall(roomId, leaveCallDto?.userId);
}
}
2 changes: 1 addition & 1 deletion src/modules/call/call.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class CallUseCase {
return {
token: callTokenData,
room: roomId,
userId: roomUser.userId,
userId: roomUser.id,
appId: this.configService.get<string>('jitsi.appId'),
};
}
Expand Down
9 changes: 1 addition & 8 deletions src/modules/call/infrastructure/room-user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class SequelizeRoomUserRepository {
}

async deleteByUserIdAndRoomId(userId: string, roomId: string): Promise<void> {
await this.roomUserModel.destroy({ where: { userId, roomId } });
await this.roomUserModel.destroy({ where: { id: userId, roomId } });
}

async findByParticipantIdAndRoomId(
Expand All @@ -95,13 +95,6 @@ export class SequelizeRoomUserRepository {
return roomUser ? RoomUser.build(roomUser) : null;
}

async deleteByParticipantIdAndRoomId(
participantId: string,
roomId: string,
): Promise<void> {
await this.roomUserModel.destroy({ where: { participantId, roomId } });
}

async destroyParticipantWithOlderTimestamp(
roomUserId: string,
participantId: string,
Expand Down
7 changes: 7 additions & 0 deletions src/modules/call/services/call.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export class CallService {
private async getMeetFeatureConfigForUser(
userUuid: string,
): Promise<Tier['featuresPerService']['meet']> {
const isProduction = this.configService.get<boolean>('isProduction')
if (!isProduction) {
return {
enabled: true,
paxPerCall: 10,
};
}
const userFeatures = await this.paymentService
.getUserTier(userUuid)
.catch((err) => {
Expand Down
17 changes: 2 additions & 15 deletions src/modules/call/services/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,10 @@ export class RoomService {
{ transaction, lock: true },
);

if (existingUser) {
if (existingUser.participantId) {
if (existingUser?.participantId) {
oldParticipantId = existingUser.participantId;
}

await this.roomUserRepository.update(
existingUser.id,
{
participantId: null,
joinedAt: null,
},
transaction,
);
}

roomUser = existingUser;
} else {
roomUser = await this.roomUserRepository.create(
{
roomId,
Expand All @@ -183,7 +171,6 @@ export class RoomService {
},
transaction,
);
}
});

return { roomUser, oldParticipantId };
Expand Down
Loading