Push Notifications Fixes - Part 2 (#12092)

* push notifications: handle some more error codes and when the user is loaded using .lean()

* fix lint

* do not send push notification if message is missing
This commit is contained in:
Matteo Pagliazzi
2020-04-15 21:36:53 +02:00
committed by GitHub
parent cc04761c24
commit c5aeab652d
8 changed files with 43 additions and 20 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ import { // eslint-disable-line import/no-cycle
import { removeFromArray } from '../libs/collectionManipulators';
import shared from '../../common';
import { sendTxn as txnEmail } from '../libs/email'; // eslint-disable-line import/no-cycle
import { sendNotification as sendPushNotification } from '../libs/pushNotifications';
import { sendNotification as sendPushNotification } from '../libs/pushNotifications'; // eslint-disable-line import/no-cycle
import { syncableAttrs, setNextDue } from '../libs/taskManager';
const { Schema } = mongoose;
+10 -7
View File
@@ -28,7 +28,7 @@ import {
} from '../libs/errors';
import baseModel from '../libs/baseModel';
import { sendTxn as sendTxnEmail } from '../libs/email'; // eslint-disable-line import/no-cycle
import { sendNotification as sendPushNotification } from '../libs/pushNotifications';
import { sendNotification as sendPushNotification } from '../libs/pushNotifications'; // eslint-disable-line import/no-cycle
import {
syncableAttrs,
} from '../libs/taskManager';
@@ -637,12 +637,15 @@ schema.methods.sendChat = function sendChat (options = {}) {
return;
}
}
sendPushNotification(member, {
identifier: 'chatMention',
title: `${user.profile.name} mentioned you in ${this.name}`,
message: newChatMessage.unformattedText,
payload: { type: this.type },
});
if (newChatMessage.unformattedText) {
sendPushNotification(member, {
identifier: 'chatMention',
title: `${user.profile.name} mentioned you in ${this.name}`,
message: newChatMessage.unformattedText,
payload: { type: this.type },
});
}
});
}
return newChatMessage;