mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: remote categories should not show up in a user's follow lists
This commit is contained in:
@@ -79,11 +79,15 @@ module.exports = function (User) {
|
||||
if (parseInt(uid, 10) <= 0) {
|
||||
return [];
|
||||
}
|
||||
const uids = await db.getSortedSetRevRange([
|
||||
let uids = await db.getSortedSetRevRange([
|
||||
`${type}:${uid}`,
|
||||
`${type}Remote:${uid}`,
|
||||
], start, stop);
|
||||
|
||||
// Filter out remote categories
|
||||
const isCategory = await db.exists(uids.map(uid => `categoryRemote:${uid}`));
|
||||
uids = uids.filter((uid, idx) => !isCategory[idx])
|
||||
|
||||
const data = await plugins.hooks.fire(`filter:user.${type}`, {
|
||||
uids: uids,
|
||||
uid: uid,
|
||||
|
||||
@@ -334,6 +334,21 @@ describe('as:Group', () => {
|
||||
assert.strictEqual(activity.type, 'Follow');
|
||||
assert.strictEqual(activity.object, cid);
|
||||
});
|
||||
|
||||
it.only('should not show up in the user\'s following list', async () => {
|
||||
await user.setCategoryWatchState(uid, cid, categories.watchStates.watching);
|
||||
|
||||
// Trigger inbox accept
|
||||
const { activity: body } = helpers.mocks.accept(cid, {
|
||||
type: 'Follow',
|
||||
actor: `${nconf.get('url')}/uid/${uid}`,
|
||||
});
|
||||
await activitypub.inbox.accept({ body });
|
||||
|
||||
const following = await user.getFollowing(uid, 0, 1);
|
||||
assert(Array.isArray(following));
|
||||
assert.strictEqual(following.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('user already following', () => {
|
||||
|
||||
@@ -106,3 +106,20 @@ Helpers.mocks.create = (object) => {
|
||||
|
||||
return { id, activity };
|
||||
};
|
||||
|
||||
Helpers.mocks.accept = (actor, object) => {
|
||||
const baseUrl = 'https://example.org';
|
||||
const uuid = utils.generateUUID();
|
||||
const id = `${baseUrl}/activity/${uuid}`;
|
||||
|
||||
const activity = {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id,
|
||||
type: 'Accept',
|
||||
to: ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
actor,
|
||||
object,
|
||||
};
|
||||
|
||||
return { activity };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user