feat: teacher invitation middelware + extra error catchings

This commit is contained in:
Gabriellvl 2025-04-18 22:33:22 +02:00
parent ac399153b6
commit f671341bad
4 changed files with 43 additions and 5 deletions

View file

@ -32,6 +32,10 @@ export async function createInvitation(data: TeacherInvitationData): Promise<Tea
throw new ConflictException('The teacher sending the invite is not part of the class');
}
if (cls.teachers.contains(receiver)){
throw new ConflictException('The teacher receiving the invite is already part of the class');
}
const newInvitation = mapToInvitation(sender, receiver, cls);
await teacherInvitationRepository.save(newInvitation, { preventOverwrite: true });