This commit is contained in:
@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import Notification from '../../../../models/notification';
|
||||
import Mute from '../../../../models/mute';
|
||||
|
||||
/**
|
||||
* Get count of unread notifications
|
||||
*/
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
const mute = await Mute.find({
|
||||
muterId: user._id
|
||||
});
|
||||
const mutedUserIds = mute.map(m => m.muteeId);
|
||||
|
||||
const count = await Notification
|
||||
.count({
|
||||
notifieeId: user._id,
|
||||
notifierId: {
|
||||
$nin: mutedUserIds
|
||||
},
|
||||
isRead: false
|
||||
});
|
||||
|
||||
res({
|
||||
count: count
|
||||
});
|
||||
});
|
@ -1,8 +1,6 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import Notification from '../../../../models/notification';
|
||||
import event from '../../../../publishers/stream';
|
||||
import User from '../../../../models/user';
|
||||
|
||||
/**
|
||||
* Mark as read all notifications
|
||||
@ -23,6 +21,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Response
|
||||
res();
|
||||
|
||||
// Update flag
|
||||
User.update({ _id: user._id }, {
|
||||
$set: {
|
||||
hasUnreadNotification: false
|
||||
}
|
||||
});
|
||||
|
||||
// 全ての通知を読みましたよというイベントを発行
|
||||
event(user._id, 'read_all_notifications');
|
||||
});
|
||||
|
Reference in New Issue
Block a user