mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
Always send push notifications in recipients language (#11307)
* Load data needed for members when inviting to quest * Always send push notifications in recipients language. Fixes #8718 * Remove console.log
This commit is contained in:
committed by
Sabe Jones
parent
14106ec5bf
commit
04420aa60e
@@ -617,7 +617,7 @@ schema.methods.startQuest = async function startQuest (user) {
|
||||
await User.find({
|
||||
_id: {$in: Object.keys(this.quest.members)},
|
||||
})
|
||||
.select('party.quest party._id items.quests auth preferences.emailNotifications preferences.pushNotifications pushDevices profile.name webhooks')
|
||||
.select('party.quest party._id items.quests auth preferences.emailNotifications preferences.pushNotifications preferences.language pushDevices profile.name webhooks')
|
||||
.lean()
|
||||
.exec()
|
||||
.then(partyMembers => {
|
||||
@@ -685,8 +685,6 @@ schema.methods.startQuest = async function startQuest (user) {
|
||||
await newMessage.save();
|
||||
|
||||
const membersToEmail = [];
|
||||
const pushTitle = quest.text();
|
||||
const pushMessage = `${shared.i18n.t('questStarted')}: ${quest.text()}`;
|
||||
|
||||
// send notifications and webhooks in the background without blocking
|
||||
members.forEach(member => {
|
||||
@@ -698,9 +696,10 @@ schema.methods.startQuest = async function startQuest (user) {
|
||||
|
||||
// send push notifications and filter users that disabled emails
|
||||
if (member.preferences.pushNotifications.questStarted !== false) {
|
||||
const memberLang = member.preferences.language;
|
||||
sendPushNotification(member, {
|
||||
title: pushTitle,
|
||||
message: pushMessage,
|
||||
title: quest.text(memberLang),
|
||||
message: `${shared.i18n.t('questStarted', memberLang)}: ${quest.text(memberLang)}`,
|
||||
identifier: 'questStarted',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user