mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00: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:
parent
14106ec5bf
commit
04420aa60e
5 changed files with 11 additions and 13 deletions
|
|
@ -79,7 +79,7 @@ api.inviteToQuest = {
|
|||
'party._id': group._id,
|
||||
_id: {$ne: user._id},
|
||||
})
|
||||
.select('auth.facebook auth.google auth.local preferences.emailNotifications profile.name pushDevices')
|
||||
.select('auth.facebook auth.google auth.local preferences.emailNotifications preferences.pushNotifications preferences.language profile.name pushDevices')
|
||||
.exec();
|
||||
|
||||
group.markModified('quest');
|
||||
|
|
@ -124,12 +124,11 @@ api.inviteToQuest = {
|
|||
sendPushNotification(
|
||||
member,
|
||||
{
|
||||
title: res.t('questInvitationTitle'),
|
||||
message: res.t('questInvitationInfo', {quest: quest.text(req.language)}),
|
||||
title: res.t('questInvitationTitle', member.preferences.language),
|
||||
message: res.t('questInvitationInfo', {quest: quest.text(member.preferences.language)}, member.preferences.language),
|
||||
identifier: 'questInvitation',
|
||||
category: 'questInvitation',
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ export async function sentMessage (sender, receiver, message, translate) {
|
|||
sendPushNotification(
|
||||
receiver,
|
||||
{
|
||||
title: translate('newPM'),
|
||||
message: translate('newPMInfo', {name: getUserInfo(sender, ['name']).name, message}),
|
||||
title: translate('newPM', receiver.preferences.language),
|
||||
message: translate('newPMInfo', {name: getUserInfo(sender, ['name']).name, message}, receiver.preferences.language),
|
||||
identifier: 'newPM',
|
||||
category: 'newPM',
|
||||
payload: {replyTo: sender._id},
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ function sendInvitePushNotification (userToInvite, groupLabel, group, publicGuil
|
|||
userToInvite,
|
||||
{
|
||||
title: group.name,
|
||||
message: res.t(identifier),
|
||||
message: res.t(identifier, userToInvite.preferences.language),
|
||||
identifier,
|
||||
payload: {groupID: group._id, publicGuild},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ schema.methods.closeChal = async function closeChal (broken = {}) {
|
|||
sendPushNotification(savedWinner,
|
||||
{
|
||||
title: challenge.name,
|
||||
message: shared.i18n.t('wonChallenge'),
|
||||
message: shared.i18n.t('wonChallenge', savedWinner.preferences.language),
|
||||
identifier: 'wonChallenge',
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue