Improve handling for sending mention notifications

This commit is contained in:
Phillip Thelen
2019-10-01 13:26:38 +02:00
parent 77b188833e
commit 2d3f2500e8
3 changed files with 36 additions and 27 deletions

View File

@@ -18,15 +18,18 @@ export async function getAuthorEmailFromMessage (message) {
}
}
export async function sendChatPushNotifications (user, group, message, translate) {
export async function sendChatPushNotifications (user, group, message, mentions, translate) {
let members = await User.find({
'party._id': group._id,
_id: {$ne: user._id},
})
.select('preferences.pushNotifications preferences.language profile.name pushDevices')
.select('preferences.pushNotifications preferences.language profile.name pushDevices auth.local.username')
.exec();
members.forEach(member => {
if (member.preferences.pushNotifications.partyActivity !== false) {
if (mentions && mentions.includes(`@${member.auth.local.username}`) && member.preferences.pushNotifications.mentionParty !== false) {
return;
}
sendPushNotification(
member,
{