Skip to content

Commit

Permalink
Merge pull request #512 from connection-2023/feature/#501
Browse files Browse the repository at this point in the history
Feat(#501): lecture not found exception
  • Loading branch information
j-zzi authored May 13, 2024
2 parents 7490bcd + 49d6b4b commit a9c09a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/chats/services/chats-room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ChatRoomService {

await Promise.all(
onlineMap.map((online) => {
if (!online.lastLogin) {
if (online && !online.lastLogin) {
this.eventsGateway.server
.to(online.socketId)
.emit('handleNewChatRoom', chatRoom.roomId);
Expand Down
4 changes: 4 additions & 0 deletions src/chats/services/chats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export class ChatsService {
roomObjectId,
);

if (!chatRoom) {
throw new NotFoundException('ChatRoom was not found', 'NotFoundChatRoom');
}

const userParticipation = chatRoom.user.participation;
const lecturerParticipation = chatRoom.lecturer.participation;

Expand Down
8 changes: 8 additions & 0 deletions src/lecture/services/lecture.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,20 @@ export class LectureService {
? await this.lectureRepository.readLecture(lectureId, userId)
: await this.lectureRepository.readLecture(lectureId);

if (!lecture) {
throw new NotFoundException('Lecture was not found', 'NotFoundLecture');
}

return new LecturePreviewDto(lecture);
}

async readLectureDetail(lectureId: number) {
const lecture = await this.lectureRepository.readLecture(lectureId);

if (!lecture) {
throw new NotFoundException('Lecture was not found', 'NotFoundLecture');
}

return new LectureDetailDto(lecture);
}

Expand Down

0 comments on commit a9c09a2

Please sign in to comment.