This commit is contained in:
syuilo 2018-05-29 01:22:39 +09:00
parent 973b1e42ef
commit ab16fb3a3f
13 changed files with 92 additions and 191 deletions

View file

@ -3,6 +3,7 @@ import Notification from '../models/notification';
import Mute from '../models/mute';
import { pack } from '../models/notification';
import stream from './stream';
import User from '../models/user';
export default (
notifiee: mongo.ObjectID,
@ -29,6 +30,13 @@ export default (
stream(notifiee, 'notification',
await pack(notification));
// Update flag
User.update({ _id: notifiee }, {
$set: {
hasUnreadNotification: true
}
});
// 3秒経っても(今回作成した)通知が既読にならなかったら「未読の通知がありますよ」イベントを発行する
setTimeout(async () => {
const fresh = await Notification.findOne({ _id: notification._id }, { isRead: true });