mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: newsletter opt-in/out in UCP, closes #21
This commit is contained in:
@@ -33,11 +33,13 @@ settingsController.get = async function (req, res, next) {
|
|||||||
userData.acpLanguages = _.cloneDeep(languagesData);
|
userData.acpLanguages = _.cloneDeep(languagesData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('dorp');
|
||||||
const data = await plugins.hooks.fire('filter:user.customSettings', {
|
const data = await plugins.hooks.fire('filter:user.customSettings', {
|
||||||
settings: settings,
|
settings: settings,
|
||||||
customSettings: [],
|
customSettings: [],
|
||||||
uid: req.uid,
|
uid: req.uid,
|
||||||
});
|
});
|
||||||
|
console.log(data.customSettings);
|
||||||
|
|
||||||
const [notificationSettings, routes] = await Promise.all([
|
const [notificationSettings, routes] = await Promise.all([
|
||||||
getNotificationSettings(userData),
|
getNotificationSettings(userData),
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ UserNotifications.get = async function (uid) {
|
|||||||
if (unread.length < 30) {
|
if (unread.length < 30) {
|
||||||
read = await getNotificationsFromSet(`uid:${uid}:notifications:read`, uid, 0, 29 - unread.length);
|
read = await getNotificationsFromSet(`uid:${uid}:notifications:read`, uid, 0, 29 - unread.length);
|
||||||
}
|
}
|
||||||
return {
|
|
||||||
|
return await plugins.hooks.fire('filter:user.notifications.get', {
|
||||||
|
uid,
|
||||||
read: read.filter(Boolean),
|
read: read.filter(Boolean),
|
||||||
unread: unread,
|
unread: unread,
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
async function filterNotifications(nids, filter) {
|
async function filterNotifications(nids, filter) {
|
||||||
@@ -133,7 +135,7 @@ UserNotifications.getUnreadCount = async function (uid) {
|
|||||||
const mergeIds = notifData.map(n => n.mergeId);
|
const mergeIds = notifData.map(n => n.mergeId);
|
||||||
|
|
||||||
// Collapse any notifications with identical mergeIds
|
// Collapse any notifications with identical mergeIds
|
||||||
return mergeIds.reduce((count, mergeId, idx, arr) => {
|
let count = mergeIds.reduce((count, mergeId, idx, arr) => {
|
||||||
// A missing (null) mergeId means that notification is counted separately.
|
// A missing (null) mergeId means that notification is counted separately.
|
||||||
if (mergeId === null || idx === arr.indexOf(mergeId)) {
|
if (mergeId === null || idx === arr.indexOf(mergeId)) {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -141,6 +143,9 @@ UserNotifications.getUnreadCount = async function (uid) {
|
|||||||
|
|
||||||
return count;
|
return count;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
({ count } = await plugins.hooks.fire('filter:user.notifications.getCount', { uid, count }));
|
||||||
|
return count;
|
||||||
};
|
};
|
||||||
|
|
||||||
UserNotifications.getUnreadByField = async function (uid, field, values) {
|
UserNotifications.getUnreadByField = async function (uid, field, values) {
|
||||||
|
|||||||
Reference in New Issue
Block a user