mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-22 20:23:49 +01:00
Fix bug and remove unnecessary query
This commit is contained in:
parent
35e7169b90
commit
e01e53c60a
@ -1,6 +1,7 @@
|
||||
import * as mongo from 'mongodb';
|
||||
import { default as Notification, INotification } from '../../../models/notification';
|
||||
import publishUserStream from '../../../publishers/stream';
|
||||
import Mute from '../../../models/mute';
|
||||
|
||||
/**
|
||||
* Mark as read notification(s)
|
||||
@ -26,6 +27,11 @@ export default (
|
||||
? [new mongo.ObjectID(message)]
|
||||
: [(message as INotification)._id];
|
||||
|
||||
const mute = await Mute.find({
|
||||
muterId: userId
|
||||
});
|
||||
const mutedUserIds = mute.map(m => m.muteeId);
|
||||
|
||||
// Update documents
|
||||
await Notification.update({
|
||||
_id: { $in: ids },
|
||||
@ -42,6 +48,9 @@ export default (
|
||||
const count = await Notification
|
||||
.count({
|
||||
notifieeId: userId,
|
||||
notifierId: {
|
||||
$nin: mutedUserIds
|
||||
},
|
||||
isRead: false
|
||||
}, {
|
||||
limit: 1
|
||||
|
@ -9,8 +9,7 @@ import Mute from '../../../../models/mute';
|
||||
*/
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
const mute = await Mute.find({
|
||||
muterId: user._id,
|
||||
deletedAt: { $exists: false }
|
||||
muterId: user._id
|
||||
});
|
||||
const mutedUserIds = mute.map(m => m.muteeId);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user