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