prevent notifications if the notification contains a note that is muted
This commit is contained in:
parent
93654b7e2c
commit
b019c704c2
|
@ -1,6 +1,6 @@
|
|||
import { publishMainStream } from '@/services/stream.js';
|
||||
import { pushNotification } from '@/services/push-notification.js';
|
||||
import { Notifications, Mutings, UserProfiles, Users } from '@/models/index.js';
|
||||
import { Notifications, Mutings, NoteThreadMutings, UserProfiles, Users } from '@/models/index.js';
|
||||
import { genId } from '@/misc/gen-id.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { Notification } from '@/models/entities/notification.js';
|
||||
|
@ -19,6 +19,17 @@ export async function createNotification(
|
|||
|
||||
const isMuted = profile?.mutingNotificationTypes.includes(type);
|
||||
|
||||
if (data.note != null) {
|
||||
const threadMute = await NoteThreadMutings.findOneBy({
|
||||
userId: notifieeId,
|
||||
threadId: data.note.threadId || data.note.id,
|
||||
});
|
||||
|
||||
if (threadMute) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Create notification
|
||||
const notification = await Notifications.insert({
|
||||
id: genId(),
|
||||
|
|
|
@ -92,6 +92,7 @@ class NotificationManager {
|
|||
createNotification(x.target, x.reason, {
|
||||
notifierId: this.notifier.id,
|
||||
noteId: this.note.id,
|
||||
note: this.note,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -394,8 +395,15 @@ export default async (user: { id: User['id']; username: User['username']; host:
|
|||
|
||||
// Notify
|
||||
if (data.renote.userHost === null) {
|
||||
const threadMuted = await NoteThreadMutings.findOneBy({
|
||||
userId: data.renote.userId,
|
||||
threadId: data.renote.threadId || data.renote.id,
|
||||
});
|
||||
|
||||
if (!threadMuted) {
|
||||
nm.push(data.renote.userId, type);
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch watchers
|
||||
nmRelatedPromises.push(notifyToWatchersOfRenotee(data.renote, user, nm, type));
|
||||
|
|
|
@ -102,6 +102,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
|
|||
if (note.userHost === null) {
|
||||
createNotification(note.userId, 'reaction', {
|
||||
notifierId: user.id,
|
||||
note: note,
|
||||
noteId: note.id,
|
||||
reaction: reaction,
|
||||
});
|
||||
|
@ -115,6 +116,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
|
|||
for (const watcher of watchers) {
|
||||
createNotification(watcher.userId, 'reaction', {
|
||||
notifierId: user.id,
|
||||
note: note,
|
||||
noteId: note.id,
|
||||
reaction: reaction,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue