feat: allow plugins to override tags and tag counts

This commit is contained in:
Julian Lam
2020-09-22 15:58:16 -04:00
parent 445a840b88
commit 81595095da

View File

@@ -109,11 +109,15 @@ module.exports = function (Topics) {
}
Topics.getTagTids = async function (tag, start, stop) {
return await db.getSortedSetRevRange('tag:' + tag + ':topics', start, stop);
const tids = await db.getSortedSetRevRange('tag:' + tag + ':topics', start, stop);
const payload = await plugins.fireHook('filter:topics.getTagTids', { tag, start, stop, tids });
return payload.tids;
};
Topics.getTagTopicCount = async function (tag) {
return await db.sortedSetCard('tag:' + tag + ':topics');
const count = await db.sortedSetCard('tag:' + tag + ':topics');
const payload = await plugins.fireHook('filter:topics.getTagTopicCount', { tag, count });
return payload.count;
};
Topics.deleteTags = async function (tags) {