mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-28 01:21:13 +01:00
Merge branch 'master' into develop
This commit is contained in:
@@ -13,6 +13,7 @@ const winston = require('winston');
|
||||
|
||||
const db = require('../database');
|
||||
const user = require('../user');
|
||||
const categories = require('../categories');
|
||||
const meta = require('../meta');
|
||||
const privileges = require('../privileges');
|
||||
const activitypub = require('../activitypub');
|
||||
@@ -43,7 +44,14 @@ activitypubApi.follow = enabledCheck(async (caller, { type, id, actor } = {}) =>
|
||||
throw new Error('[[error:activitypub.invalid-id]]');
|
||||
}
|
||||
|
||||
actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor;
|
||||
if (actor.includes('@')) {
|
||||
const [uid, cid] = await Promise.all([
|
||||
user.getUidByUserslug(actor),
|
||||
categories.getCidByHandle(actor),
|
||||
]);
|
||||
|
||||
actor = uid || cid;
|
||||
}
|
||||
|
||||
const isFollowing = await db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor);
|
||||
if (isFollowing) { // already following
|
||||
@@ -73,10 +81,21 @@ activitypubApi.unfollow = enabledCheck(async (caller, { type, id, actor }) => {
|
||||
throw new Error('[[error:activitypub.invalid-id]]');
|
||||
}
|
||||
|
||||
actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor;
|
||||
if (actor.includes('@')) {
|
||||
const [uid, cid] = await Promise.all([
|
||||
user.getUidByUserslug(actor),
|
||||
categories.getCidByHandle(actor),
|
||||
]);
|
||||
|
||||
const isFollowing = await db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor);
|
||||
if (!isFollowing) { // already not following
|
||||
actor = uid || cid;
|
||||
}
|
||||
|
||||
const [isFollowing, isPending] = await Promise.all([
|
||||
db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor),
|
||||
db.isSortedSetMember(`followRequests:${type === 'uid' ? 'uid' : 'cid'}.${id}`, actor),
|
||||
]);
|
||||
|
||||
if (!isFollowing && !isPending) { // already not following/pending
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,13 @@ Categories.getCategoryById = async function (data) {
|
||||
};
|
||||
|
||||
Categories.getCidByHandle = async function (handle) {
|
||||
return await db.sortedSetScore('categoryhandle:cid', handle);
|
||||
let cid = await db.sortedSetScore('categoryhandle:cid', handle);
|
||||
if (!cid) {
|
||||
// remote cids
|
||||
cid = await db.getObjectField('handle:cid', handle);
|
||||
}
|
||||
|
||||
return cid;
|
||||
};
|
||||
|
||||
Categories.getAllCidsFromSet = async function (key) {
|
||||
|
||||
12
src/upgrades/4.3.2/fix_category_sync_null_values.js
Normal file
12
src/upgrades/4.3.2/fix_category_sync_null_values.js
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const db = require('../../database');
|
||||
|
||||
module.exports = {
|
||||
name: 'Fix null values in category synchronization list',
|
||||
timestamp: Date.UTC(2025, 4, 8),
|
||||
method: async () => {
|
||||
const cids = await db.getSortedSetMembers('categories:cid');
|
||||
await db.sortedSetsRemove(cids.map(cid => `followRequests:cid.${cid}`), 'null');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user