fix: Replies to comments in threads only trigger notifications to document subscribers, closes #4984
This commit is contained in:
@@ -51,8 +51,9 @@ export default class NotificationHelper {
|
|||||||
): Promise<NotificationSetting[]> => {
|
): Promise<NotificationSetting[]> => {
|
||||||
const recipients = await this.getDocumentNotificationRecipients(
|
const recipients = await this.getDocumentNotificationRecipients(
|
||||||
document,
|
document,
|
||||||
"documents.update",
|
"comments.create",
|
||||||
actorId
|
actorId,
|
||||||
|
!comment.parentCommentId
|
||||||
);
|
);
|
||||||
|
|
||||||
if (recipients.length > 0 && comment.parentCommentId) {
|
if (recipients.length > 0 && comment.parentCommentId) {
|
||||||
@@ -76,15 +77,18 @@ export default class NotificationHelper {
|
|||||||
/**
|
/**
|
||||||
* Get the recipients of a notification for a document event.
|
* Get the recipients of a notification for a document event.
|
||||||
*
|
*
|
||||||
* @param document The document to get recipients for
|
* @param document The document to get recipients for.
|
||||||
* @param eventName The event name
|
* @param eventName The event name.
|
||||||
* @param actorId The id of the user that performed the action
|
* @param actorId The id of the user that performed the action.
|
||||||
|
* @param onlySubscribers Whether to only return recipients that are actively
|
||||||
|
* subscribed to the document.
|
||||||
* @returns A list of recipients
|
* @returns A list of recipients
|
||||||
*/
|
*/
|
||||||
public static getDocumentNotificationRecipients = async (
|
public static getDocumentNotificationRecipients = async (
|
||||||
document: Document,
|
document: Document,
|
||||||
eventName: string,
|
eventName: string,
|
||||||
actorId: string
|
actorId: string,
|
||||||
|
onlySubscribers: boolean
|
||||||
): Promise<NotificationSetting[]> => {
|
): Promise<NotificationSetting[]> => {
|
||||||
// First find all the users that have notifications enabled for this event
|
// First find all the users that have notifications enabled for this event
|
||||||
// type at all and aren't the one that performed the action.
|
// type at all and aren't the one that performed the action.
|
||||||
@@ -98,9 +102,8 @@ export default class NotificationHelper {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the event is a revision creation we can filter further to only those
|
// Filter further to only those that have a subscription to the document…
|
||||||
// that have a subscription to the document…
|
if (onlySubscribers) {
|
||||||
if (eventName === "documents.update") {
|
|
||||||
const subscriptions = await Subscription.findAll({
|
const subscriptions = await Subscription.findAll({
|
||||||
attributes: ["userId"],
|
attributes: ["userId"],
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ export default class NotificationsProcessor extends BaseProcessor {
|
|||||||
const recipients = await NotificationHelper.getDocumentNotificationRecipients(
|
const recipients = await NotificationHelper.getDocumentNotificationRecipients(
|
||||||
document,
|
document,
|
||||||
"documents.publish",
|
"documents.publish",
|
||||||
document.lastModifiedById
|
document.lastModifiedById,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const recipient of recipients) {
|
for (const recipient of recipients) {
|
||||||
@@ -128,7 +129,8 @@ export default class NotificationsProcessor extends BaseProcessor {
|
|||||||
const recipients = await NotificationHelper.getDocumentNotificationRecipients(
|
const recipients = await NotificationHelper.getDocumentNotificationRecipients(
|
||||||
document,
|
document,
|
||||||
"documents.update",
|
"documents.update",
|
||||||
document.lastModifiedById
|
document.lastModifiedById,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
if (!recipients.length) {
|
if (!recipients.length) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user