@ -9,6 +9,8 @@ const meta = require('../meta');
const notifications = require ( '../notifications' ) ;
const notifications = require ( '../notifications' ) ;
const privileges = require ( '../privileges' ) ;
const privileges = require ( '../privileges' ) ;
const plugins = require ( '../plugins' ) ;
const plugins = require ( '../plugins' ) ;
const translator = require ( '../translator' ) ;
const user = require ( './index' ) ;
const utils = require ( '../utils' ) ;
const utils = require ( '../utils' ) ;
const UserNotifications = module . exports ;
const UserNotifications = module . exports ;
@ -99,9 +101,10 @@ UserNotifications.getNotifications = async function (nids, uid) {
return [ ] ;
return [ ] ;
}
}
const [ notifObjs , hasRead ] = await Promise . all ( [
const [ notifObjs , hasRead , userSettings ] = await Promise . all ( [
notifications . getMultiple ( nids ) ,
notifications . getMultiple ( nids ) ,
db . isSortedSetMembers ( ` uid: ${ uid } :notifications:read ` , nids ) ,
db . isSortedSetMembers ( ` uid: ${ uid } :notifications:read ` , nids ) ,
user . getSettings ( uid ) ,
] ) ;
] ) ;
const deletedNids = [ ] ;
const deletedNids = [ ] ;
@ -119,6 +122,12 @@ UserNotifications.getNotifications = async function (nids, uid) {
await deleteUserNids ( deletedNids , uid ) ;
await deleteUserNids ( deletedNids , uid ) ;
notificationData = await notifications . merge ( notificationData ) ;
notificationData = await notifications . merge ( notificationData ) ;
await Promise . all ( notificationData . map ( async ( n ) => {
if ( n && n . bodyShort ) {
n . bodyShort = await translator . translate ( n . bodyShort , userSettings . userLang ) ;
}
} ) ) ;
const result = await plugins . hooks . fire ( 'filter:user.notifications.getNotifications' , {
const result = await plugins . hooks . fire ( 'filter:user.notifications.getNotifications' , {
uid : uid ,
uid : uid ,
notifications : notificationData ,
notifications : notificationData ,