mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
feat: fire hook to allow plugins to filter the pids returned in a user profile
/cc julianlam/nodebb-plugin-support-forum#14
This commit is contained in:
@@ -7,6 +7,7 @@ const db = require('../../database');
|
|||||||
const user = require('../../user');
|
const user = require('../../user');
|
||||||
const posts = require('../../posts');
|
const posts = require('../../posts');
|
||||||
const categories = require('../../categories');
|
const categories = require('../../categories');
|
||||||
|
const plugins = require('../../plugins');
|
||||||
const meta = require('../../meta');
|
const meta = require('../../meta');
|
||||||
const privileges = require('../../privileges');
|
const privileges = require('../../privileges');
|
||||||
const accountHelpers = require('./helpers');
|
const accountHelpers = require('./helpers');
|
||||||
@@ -106,11 +107,17 @@ async function getPosts(callerUid, userData, setSuffix) {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
const pids = await db.getSortedSetRevRange(keys, start, start + count - 1);
|
let pids = await db.getSortedSetRevRange(keys, start, start + count - 1);
|
||||||
if (!pids.length || pids.length < count) {
|
if (!pids.length || pids.length < count) {
|
||||||
hasMorePosts = false;
|
hasMorePosts = false;
|
||||||
}
|
}
|
||||||
if (pids.length) {
|
if (pids.length) {
|
||||||
|
({ pids } = await plugins.hooks.fire('filter:account.profile.getPids', {
|
||||||
|
uid: callerUid,
|
||||||
|
userData,
|
||||||
|
setSuffix,
|
||||||
|
pids,
|
||||||
|
}));
|
||||||
const p = await posts.getPostSummaryByPids(pids, callerUid, { stripTags: false });
|
const p = await posts.getPostSummaryByPids(pids, callerUid, { stripTags: false });
|
||||||
postData.push(...p.filter(
|
postData.push(...p.filter(
|
||||||
p => p && p.topic && (isAdmin || cidToIsMod[p.topic.cid] ||
|
p => p && p.topic && (isAdmin || cidToIsMod[p.topic.cid] ||
|
||||||
|
|||||||
Reference in New Issue
Block a user