<commit_before>// send notification email about reserved appointment to student and assistant
// studentId is needed as a parameter, as it might not be in db yet.
sendReservationEmails = function(studentId, appointmentId) {
    var data = getAppointmentInfo(studentId, appointmentId);

    // Send two separate emails so that students don't see assistant name
    var mail = formatEmail(data, 'studentReserve');
    mail.subject = data.course.code + ' appointment reserved';
    mail.to = contactEmail(data.student);
    Email.send(mail);
    mail = formatEmail(data, 'assistantReserve');
    mail.subject = data.course.code + ' appointment reserved';
    mail.to = contactEmail(data.assistant);
    try {
        Email.send(mail);
    } catch (e) {
        throw new Meteor.Error(500, 'error while sending email to: ' + mail.to, e);
    }
};

// send notification email about cancelled appointment to student and assistant
// studentId is needed as a parameter, as it might have been removed from db.
sendCancellationEmails = function(studentId, appointmentId) {
    var data = getAppointmentInfo(studentId, appointmentId);

    // Send two separate emails so that students don't see assistant name
    var mail = formatEmail(data, 'studentCancel');
    mail.subject = data.course.code + ' appointment cancelled';
    mail.to = contactEmail(data.student);
    Email.send(mail);
    mail = formatEmail(data, 'assistantCancel');
    mail.subject = data.course.code + ' appointment cancelled';
    mail.to = contactEmail(data.assistant);
    try {
        Email.send(mail);
    } catch (e) {
        throw new Meteor.Error(500, 'error while sending email to: ' + mail.to, e);
    }
};

sendCourseEnrolmentEmail = function(user, course) {
    var content = Handlebars.templates['enrollmentEmail']({
        url: Router.routes['home'].url(),
        courseName: course.name,
        courseCode: course.code,
        email: user.emails[0],
    });
    var mail = {
        from: course.email,
        replyTo: course.email,
        to: user.emails[0],
        subject: 'Registration to ' + course.name + ' appointment reservation system',
        text: content
    };
    try {
        Email.send(mail);
    } catch (e) {
        throw new Meteor.Error(500, 'error while sending email to: ' + mail.to, e);
    }
};

sendRegistrationEmail = function(email, password, course) {
    var content = Handlebars.templates['registrationEmail']({
        url: Router.routes['home'].url(),
        courseName: course.name,
        courseCode: course.code,
        email: email,
        password: password
    });
    var mail = {
        from: course.email,
        replyTo: course.email,
        to: email,
        subject: 'Registration to ' + course.name + ' appointment reservation system',
        text: content
    };
    try {
        Email.send(mail);
    } catch (e) {
        throw new Meteor.Error(500, 'error while sending email to: ' + mail.to, e);<commit_msg>Fix enrollment email sending. Still need to work a lot on email sending error handling.<commit_after>// send notification email about reserved appointment to student and assistant
// studentId is needed as a parameter, as it might not be in db yet.
sendReservationEmails = function(studentId, appointmentId) {
    var data = getAppointmentInfo(studentId, appointmentId);

    // Send two separate emails so that students don't see assistant name
    var mail = formatEmail(data, 'studentReserve');
    mail.subject = data.course.code + ' appointment reserved';
    mail.to = contactEmail(data.student);
    Email.send(mail);
    mail = formatEmail(data, 'assistantReserve');
    mail.subject = data.course.code + ' appointment reserved';
    mail.to = contactEmail(data.assistant);
    try {
        Email.send(mail);
    } catch (e) {
        throw new Meteor.Error(500, 'error while sending email to: ' + mail.to, e);
    }
};

// send notification email about cancelled appointment to student and assistant
// studentId is needed as a parameter, as it might have been removed from db.
sendCancellationEmails = function(studentId, appointmentId) {
    var data = getAppointmentInfo(studentId, appointmentId);

    // Send two separate emails so that students don't see assistant name
    var mail = formatEmail(data, 'studentCancel');
    mail.subject = data.course.code + ' appointment cancelled';
    mail.to = contactEmail(data.student);
    Email.send(mail);
    mail = formatEmail(data, 'assistantCancel');
    mail.subject = data.course.code + ' appointment cancelled';
    mail.to = contactEmail(data.assistant);
    try {
        Email.send(mail);
    } catch (e) {
        throw new Meteor.Error(500, 'error while sending email to: ' + mail.to, e);
    }
};

sendCourseEnrolmentEmail = function(user, course) {
    var content = Handlebars.templates['enrollmentEmail']({
        url: Router.routes['home'].url(),
        courseName: course.name,
        courseCode: course.code,
        email: user.emails[0],
    });
    var mail = {
        from: course.email,
        replyTo: course.email,
        to: user.emails[0].address,
        subject: 'Registration to ' + course.name + ' appointment reservation system',
        text: content
    };
    try {
        Email.send(mail);
    } catch (e) {
        throw new Meteor.Error(500, 'error while sending email to: ' + mail.to, e);
    }
};

sendRegistrationEmail = function(email, password, course) {
    var content = Handlebars.templates['registrationEmail']({
        url: Router.routes['home'].url(),
        courseName: course.name,
        courseCode: course.code,
        email: email,
        password: password
    });
    var mail = {
        from: course.email,
        replyTo: course.email,
        to: email,
        subject: 'Registration to ' + course.name + ' appointment reservation system',
        text: content
    };
    try {
        Email.send(mail);
    } catch (e) {
        console.log(e);
        throw new Meteor.Error(500, 'error while sending email to: ' + mail.to, e);
{'fraction_non_alphanumeric': 0.1147459315841913, 'fraction_numerical': 0.004649618067087346, 'mean_word_length': 2.8958602846054333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3899999', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1681, 'n_words': 506}