mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: pending follows and logic for remote users, #12938
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
"profile-flagged": "Already flagged",
|
||||
"follow": "Follow",
|
||||
"unfollow": "Unfollow",
|
||||
"cancel-follow": "Cancel follow request",
|
||||
"more": "More",
|
||||
|
||||
"profile-update-success": "Profile has been updated successfully!",
|
||||
|
||||
@@ -90,6 +90,7 @@ activitypubApi.unfollow = enabledCheck(async (caller, { type, id, actor }) => {
|
||||
if (type === 'uid') {
|
||||
await Promise.all([
|
||||
db.sortedSetRemove(`followingRemote:${id}`, actor),
|
||||
db.sortedSetRemove(`followRequests:uid.${id}`, actor),
|
||||
db.decrObjectField(`user:${id}`, 'followingRemoteCount'),
|
||||
]);
|
||||
} else if (type === 'cid') {
|
||||
|
||||
@@ -88,6 +88,7 @@ helpers.getUserDataByUserSlug = async function (userslug, callerUID, query = {})
|
||||
userData.canChangePassword = isAdmin || (isSelf && !meta.config['password:disableEdit']);
|
||||
userData.isSelf = isSelf;
|
||||
userData.isFollowing = results.isFollowing;
|
||||
userData.isFollowPending = results.isFollowPending;
|
||||
userData.canChat = results.canChat;
|
||||
userData.hasPrivateChat = results.hasPrivateChat;
|
||||
userData.iconBackgrounds = results.iconBackgrounds;
|
||||
@@ -230,6 +231,7 @@ async function getAllData(uid, callerUID) {
|
||||
isGlobalModerator: isGlobalModerator,
|
||||
isModerator: user.isModeratorOfAnyCategory(callerUID),
|
||||
isFollowing: user.isFollowing(callerUID, uid),
|
||||
isFollowPending: user.isFollowPending(callerUID, uid),
|
||||
ips: user.getIPs(uid, 4),
|
||||
profile_menu: getProfileMenu(uid, callerUID),
|
||||
groups: groups.getUserGroups([uid]),
|
||||
|
||||
@@ -5,6 +5,7 @@ const notifications = require('../notifications');
|
||||
const plugins = require('../plugins');
|
||||
const activitypub = require('../activitypub');
|
||||
const db = require('../database');
|
||||
const utils = require('../utils');
|
||||
|
||||
module.exports = function (User) {
|
||||
User.follow = async function (uid, followuid) {
|
||||
@@ -104,6 +105,14 @@ module.exports = function (User) {
|
||||
return await db.isSortedSetMember(`${setPrefix}:${uid}`, theirid);
|
||||
};
|
||||
|
||||
User.isFollowPending = async function (uid, target) {
|
||||
if (utils.isNumber(target)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return await db.isSortedSetMember(`followRequests:uid.${uid}`, target);
|
||||
};
|
||||
|
||||
User.onFollow = async function (uid, targetUid) {
|
||||
const userData = await User.getUserFields(uid, ['username', 'userslug']);
|
||||
const { displayname } = userData;
|
||||
|
||||
Reference in New Issue
Block a user