feat: add action:topics.scheduled.notify

add missing notify calls into scheduled topics
This commit is contained in:
Barış Soner Uşaklı
2024-09-10 09:38:05 -04:00
parent d348d1dfd7
commit 705796f628
2 changed files with 11 additions and 2 deletions

View File

@@ -8,8 +8,10 @@ const db = require('../database');
const posts = require('../posts');
const socketHelpers = require('../socket.io/helpers');
const topics = require('./index');
const categories = require('../categories');
const groups = require('../groups');
const user = require('../user');
const plugins = require('../plugins');
const Scheduled = module.exports;
@@ -117,13 +119,21 @@ async function sendNotifications(uids, topicsData) {
}
});
return Promise.all(topicsData.map(
await Promise.all(topicsData.map(
(t, idx) => user.notifications.sendTopicNotificationToFollowers(t.uid, t, postsData[idx])
).concat(
postsData.map(p => topics.notifyTagFollowers(p, p.uid))
).concat(
postsData.map(p => categories.notifyCategoryFollowers(p, p.uid))
).concat(
topicsData.map(
(t, idx) => socketHelpers.notifyNew(t.uid, 'newTopic', { posts: [postsData[idx]], topic: t })
)
));
plugins.hooks.fire('action:topics.scheduled.notify', {
posts: postsData,
topics: topicsData,
});
}
async function updateUserLastposttimes(uids, topicsData) {

View File

@@ -588,7 +588,6 @@ module.exports = function (Topics) {
};
Topics.notifyTagFollowers = async function (postData, exceptUid) {
console.log();
let { tags } = postData.topic;
if (!tags.length) {
return;