Skip to content

Commit

Permalink
과외 종료시 채팅방에 메시지 전송. 과외 종료되면 토큰 생성 안해줌.
Browse files Browse the repository at this point in the history
  • Loading branch information
seongyunlee committed Oct 6, 2023
1 parent 5995b8f commit 7e4ad8a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/tutoring/tutoring.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,24 @@ export class TutoringService {
'finished',
);

const finishMessage = {
startAt: tutoring.startedAt,
endAt: tutoring.endedAt,
};

await this.socketRepository.sendMessageToBothUser(
tutoring.teacherId,
tutoring.studentId,
tutoring.questionId,
'tutoring-finished',
JSON.stringify(finishMessage),
);

//TODO : 과외 종료시, 과외에 참여한 학생과 선생님의 포인트를 수정하는 로직 추가

return new Success('과외가 종료되었습니다.', { tutoringId });
} catch (error) {
return new Fail(error.message);
return new Fail('과외를 종료할 수 없습니다.');
}
}

Expand Down Expand Up @@ -126,6 +141,9 @@ export class TutoringService {
return new Fail('해당 과외 정보를 볼 수 없습니다.');
}
const tutoring = await this.tutoringRepository.get(question.tutoringId);
if (tutoring.status == 'finished') {
return new Fail('과외가 종료되었습니다.');
}
const tutoringInfo: TutoringInfo = {
id: tutoring.id,
questionId: tutoring.questionId,
Expand Down Expand Up @@ -174,6 +192,10 @@ export class TutoringService {
if (tutoring.teacherId != teacherId) {
return new Fail('해당 과외를 진행할 수 없습니다.');
}
if (tutoring.status == 'finished') {
return new Fail('이미 종료된 과외입니다.');
}

await this.tutoringRepository.startTutoring(tutoringId);

return await this.classroomInfo(tutoring.id, teacherId);
Expand Down

0 comments on commit 7e4ad8a

Please sign in to comment.