Commit c6863725 authored by Klaus-Dieter Quibeldey-Cirkel's avatar Klaus-Dieter Quibeldey-Cirkel 🏀

Staging

parent f0001c19
......@@ -1689,14 +1689,13 @@
"textEnd": " zu lernen sind. ",
"newCards2Singular": " Karte aus der Kartei ",
"newCards2Plural": " Karten aus der Kartei ",
"textIntro": "Hallo, ",
"textIntro": "Hallo __firstName__,",
"textIntro1": "es ist an der Zeit, einen Blick auf deine Lernkarten zu werfen! ",
"textDate1": "Du hast noch bis <strong>",
"textDate2": "</strong> Zeit, um die Karten zu lernen.",
"mailCard": "die Kartei <strong>&raquo;",
"mailCard1": "&laquo;</strong> benötigt deine Aufmerksamkeit: In Kürze setzt der Leitner-Algorithmus deine Lernstatistik zurück, wenn du dein Lernpensum nicht erfüllst. ",
"subjectEnding": "endet die Lernphase der Kartei ",
"textIntroEnding": "Hallo, ",
"textEnding": "heute endet die Lernphase der Kartei ",
"subjectReset": "Deine Lernstatistik wird in Kürze zurückgesetzt für die Kartei ",
"textReset": "wegen Inaktivität wurde deine Lernstatistik zurückgesetzt. ",
......
......@@ -12,9 +12,10 @@ import {WebPushSubscriptions} from "./webPushSubscriptions";
* Returns the degree, the givenname and the birthname from the author of a cardset
* @param owner - The database ID of the author
* @param lastNameFirst - Display the last name first
* @param onlyFirstName - Return only the first name, used for E-Mail Notifications
* @returns {*} - Degree + givenname + birthname
*/
export function getAuthorName(owner, lastNameFirst = true) {
export function getAuthorName(owner, lastNameFirst = true, onlyFirstName = false) {
let author;
if (Meteor.isServer) {
author = Meteor.users.findOne({"_id": owner});
......@@ -32,6 +33,13 @@ export function getAuthorName(owner, lastNameFirst = true) {
}
if (author) {
let name = "";
if (onlyFirstName) {
if (author.profile.givenname) {
return author.profile.givenname.split(" ", 1);
} else {
return name;
}
}
if (lastNameFirst) {
if (author.profile.birthname) {
name += author.profile.birthname;
......
......@@ -55,9 +55,10 @@ export class MailNotifier {
throw new Meteor.Error("not-authorized");
} else {
var notifier = new Notifications();
var firstName = getAuthorName(user_id, false, true);
var cards = notifier.getActiveCardsCount(cardset._id, user_id);
var subject = TAPi18n.__('mailNotification.subjectTitle', {lastAppTitle: Meteor.settings.public.welcome.title.last}, Meteor.settings.mail.language);
var name = TAPi18n.__('mailNotification.textIntro', null, Meteor.settings.mail.language) + getAuthorName(user_id, false) + ",";
var name = TAPi18n.__('mailNotification.textIntro', {firstName: firstName[0]}, Meteor.settings.mail.language);
var text = TAPi18n.__('mailNotification.textIntro1', null, Meteor.settings.mail.language) + TAPi18n.__('mailNotification.newCards1', null, Meteor.settings.mail.language);
var bold;
var textEnd;
......@@ -83,10 +84,10 @@ export class MailNotifier {
if (!Meteor.isServer) {
throw new Meteor.Error("not-authorized");
} else {
var notifier = new Notifications();
var firstName = getAuthorName(user_id, false, true);
var subject = TAPi18n.__('mailNotification.subjectReset', null, Meteor.settings.mail.language) + '»' + cardset.name + '«.';
var text = TAPi18n.__('mailNotification.mailCard', null, Meteor.settings.mail.language) + cardset.name + TAPi18n.__('mailNotification.mailCard1', null, Meteor.settings.mail.language) + "\n\n";
var name = TAPi18n.__('mailNotification.textIntro', null, Meteor.settings.mail.language) + notifier.getName(user_id) + ",";
var name = TAPi18n.__('mailNotification.textIntro', {firstName: firstName[0]}, Meteor.settings.mail.language);
text += this.getDeadline(cardset, user_id);
this.sendMail(name, this.getMail(user_id), subject, text, "", "", cardset._id, "#FE5E3E", "#33D275");
}
......@@ -115,6 +116,7 @@ export class MailNotifier {
throw new Meteor.Error("not-authorized");
} else {
if (mail) {
console.log(name);
var html = SSR.render("newsletter", {
name: name,
message: text,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment