mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: closes #11812, add unread public rooms into digest
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
"reset.notify.text1": "We are notifying you that on %1, your password was changed successfully.",
|
||||
"reset.notify.text2": "If you did not authorise this, please notify an administrator immediately.",
|
||||
|
||||
"digest.unread-rooms": "Unread rooms",
|
||||
"digest.room-name-unreadcount": "%1 (%2 unread)",
|
||||
"digest.latest_topics": "Latest topics from %1",
|
||||
"digest.top-topics": "Top topics from %1",
|
||||
"digest.popular-topics": "Popular topics from %1",
|
||||
|
||||
@@ -8,6 +8,7 @@ const batch = require('../batch');
|
||||
const meta = require('../meta');
|
||||
const user = require('./index');
|
||||
const topics = require('../topics');
|
||||
const messaging = require('../messaging');
|
||||
const plugins = require('../plugins');
|
||||
const emailer = require('../emailer');
|
||||
const utils = require('../utils');
|
||||
@@ -94,13 +95,16 @@ Digest.send = async function (data) {
|
||||
return;
|
||||
}
|
||||
await Promise.all(userData.map(async (userObj) => {
|
||||
const [notifications, topics] = await Promise.all([
|
||||
const [publicRooms, notifications, topics] = await Promise.all([
|
||||
getUnreadPublicRooms(userObj.uid),
|
||||
user.notifications.getUnreadInterval(userObj.uid, data.interval),
|
||||
getTermTopics(data.interval, userObj.uid),
|
||||
]);
|
||||
const unreadNotifs = notifications.filter(Boolean);
|
||||
// If there are no notifications and no new topics, don't bother sending a digest
|
||||
if (!unreadNotifs.length && !topics.top.length && !topics.popular.length && !topics.recent.length) {
|
||||
// If there are no notifications and no new topics and no unread chats, don't bother sending a digest
|
||||
if (!unreadNotifs.length &&
|
||||
!topics.top.length && !topics.popular.length && !topics.recent.length &&
|
||||
!publicRooms.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,6 +124,7 @@ Digest.send = async function (data) {
|
||||
username: userObj.username,
|
||||
userslug: userObj.userslug,
|
||||
notifications: unreadNotifs,
|
||||
publicRooms: publicRooms,
|
||||
recent: topics.recent,
|
||||
topTopics: topics.top,
|
||||
popularTopics: topics.popular,
|
||||
@@ -212,3 +217,8 @@ async function getTermTopics(term, uid) {
|
||||
});
|
||||
return { top, popular, recent };
|
||||
}
|
||||
|
||||
async function getUnreadPublicRooms(uid) {
|
||||
const publicRooms = await messaging.getPublicRooms(uid, uid);
|
||||
return publicRooms.filter(r => r && r.unread);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,26 @@
|
||||
</td>
|
||||
</tr>
|
||||
{{{ end }}}
|
||||
{{{ if publicRooms.length }}}
|
||||
<tr>
|
||||
<td style="padding: 0px 40px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 15px; line-height: 20px; color: #555555;">
|
||||
<h1 style="margin: 16px 0 24px 0; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 18px; line-height: 21px; color: #aaaaaa; font-weight: normal;">[[email:digest.unread-rooms]]</h1>
|
||||
<ul style="margin: 0; padding: 0;">
|
||||
{{{ each publicRooms }}}
|
||||
<li style="text-decoration: none; list-style-type: none; padding-bottom: 0.5em;">
|
||||
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="padding: 16px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; line-height: 16px; color: #333333;">
|
||||
<p style="margin: 0;"><a style="text-decoration:none !important; text-decoration:none; color: #333333;" href="{url}/chats/{./roomId}"># [[email:digest.room-name-unreadcount, {./roomName}, {./unreadCountText}]]</a></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
{{{ end }}}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{{{ end }}}
|
||||
{{{ if topTopics.length }}}
|
||||
<tr>
|
||||
<td style="padding: 0px 40px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 15px; line-height: 20px; color: #555555;">
|
||||
|
||||
Reference in New Issue
Block a user