mirror of
https://github.com/danbulant/ssps-bot
synced 2026-06-24 17:11:50 +00:00
vytváření studenta v databázi
This commit is contained in:
parent
6162fbccf4
commit
b1b82bfa5e
1 changed files with 4 additions and 2 deletions
|
|
@ -126,14 +126,16 @@ sequelize.afterBulkSync(async () => {
|
||||||
|
|
||||||
if(api.isStudentMail(user.email)) {
|
if(api.isStudentMail(user.email)) {
|
||||||
if(!user.class) continue;
|
if(!user.class) continue;
|
||||||
user.class = user.class.replace(/ |\./, "").toUpperCase();
|
user.class = user.class.replace(/ |\./g, "").toUpperCase();
|
||||||
var student = await Student.findOne({
|
var student = await Student.findOne({
|
||||||
where: {
|
where: {
|
||||||
personId: person.id
|
personId: person.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(!student) {
|
if(!student) {
|
||||||
await Person.create({
|
await Student.create({
|
||||||
|
id: user.email.split("@")[0],
|
||||||
|
classId: api.map[user.class],
|
||||||
personId: person.id,
|
personId: person.id,
|
||||||
name: person.name
|
name: person.name
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue