Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ST-684] 과외 종료시 채팅방에 메시지 전송. 과외 종료되면 토큰 생성 안해줌. #78

Merged
merged 2 commits into from
Oct 8, 2023
Merged
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
26 changes: 24 additions & 2 deletions 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 @@ -93,9 +108,12 @@ export class TutoringService {
return new Fail('해당 과외 정보가 없습니다.');
}

if (userInfo.role == 'student' && tutoring.status != 'going') {
if (userInfo.role == 'student' && tutoring.status == 'reserved') {
return new Fail('수업 시작 전입니다.');
}
if (userInfo.role == 'student' && tutoring.status == 'finished') {
return new Fail('수업이 종료되었습니다.');
}
const whiteBoardToken = await this.agoraService.makeWhiteBoardToken(
tutoring.whiteBoardUUID,
);
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