mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-31 11:50:08 +01:00
Merge remote-tracking branch 'origin/develop' into activitypub
This commit is contained in:
@@ -29,7 +29,7 @@ editController.get = async function (req, res, next) {
|
||||
const [canUseSignature, canManageUsers, customUserFields] = await Promise.all([
|
||||
privileges.global.can('signature', req.uid),
|
||||
privileges.admin.can('admin:users', req.uid),
|
||||
accountHelpers.getCustomUserFields(userData),
|
||||
accountHelpers.getCustomUserFields(req.uid, userData),
|
||||
]);
|
||||
|
||||
userData.customUserFields = customUserFields;
|
||||
|
||||
@@ -139,7 +139,7 @@ helpers.getUserDataByUserSlug = async function (userslug, callerUID, query = {})
|
||||
return hookData.userData;
|
||||
};
|
||||
|
||||
helpers.getCustomUserFields = async function (userData) {
|
||||
helpers.getCustomUserFields = async function (callerUID, userData) {
|
||||
// Remote users' fields are serialized in hash
|
||||
if (!utils.isNumber(userData.uid)) {
|
||||
const customFields = await user.getUserField(userData.uid, 'customFields');
|
||||
@@ -165,9 +165,22 @@ helpers.getCustomUserFields = async function (userData) {
|
||||
const keys = await db.getSortedSetRange('user-custom-fields', 0, -1);
|
||||
const allFields = (await db.getObjects(keys.map(k => `user-custom-field:${k}`))).filter(Boolean);
|
||||
|
||||
const isSelf = String(callerUID) === String(userData.uid);
|
||||
const [isAdmin, isModOfAny] = await Promise.all([
|
||||
privileges.users.isAdministrator(callerUID),
|
||||
user.isModeratorOfAnyCategory(callerUID),
|
||||
]);
|
||||
|
||||
const fields = allFields.filter((field) => {
|
||||
const visibilityCheck = isAdmin || isModOfAny || isSelf || field.visibility === 'all' ||
|
||||
(
|
||||
field.visibility === 'loggedin' &&
|
||||
String(callerUID) !== '0' &&
|
||||
String(callerUID) !== '-1'
|
||||
);
|
||||
const minRep = field['min:rep'] || 0;
|
||||
return userData.reputation >= minRep || meta.config['reputation:disabled'];
|
||||
const repCheck = userData.reputation >= minRep || meta.config['reputation:disabled'];
|
||||
return visibilityCheck && repCheck;
|
||||
});
|
||||
|
||||
fields.forEach((f) => {
|
||||
|
||||
@@ -27,7 +27,7 @@ profileController.get = async function (req, res, next) {
|
||||
const [latestPosts, bestPosts, customUserFields] = await Promise.all([
|
||||
getLatestPosts(req.uid, userData),
|
||||
getBestPosts(req.uid, userData),
|
||||
accountHelpers.getCustomUserFields(userData),
|
||||
accountHelpers.getCustomUserFields(req.uid, userData),
|
||||
posts.parseSignature(userData, req.uid),
|
||||
]);
|
||||
userData.customUserFields = customUserFields;
|
||||
|
||||
@@ -310,6 +310,7 @@ usersController.customFields = async function (req, res) {
|
||||
field.selectOptionsFormatted = field['select-options'].trim().split('\n').join(', ');
|
||||
}
|
||||
field['min:rep'] = field['min:rep'] || 0;
|
||||
field.visibility = field.visibility || 'all';
|
||||
});
|
||||
res.render('admin/manage/users/custom-fields', { fields: fields });
|
||||
};
|
||||
|
||||
@@ -110,12 +110,16 @@ async function resizeImage(fileObj) {
|
||||
|
||||
await image.resizeImage({
|
||||
path: fileObj.path,
|
||||
target: file.appendToFileName(fileObj.path, '-resized'),
|
||||
target: meta.config.resizeImageKeepOriginal ?
|
||||
file.appendToFileName(fileObj.path, '-resized') :
|
||||
fileObj.path,
|
||||
width: meta.config.resizeImageWidth,
|
||||
quality: meta.config.resizeImageQuality,
|
||||
});
|
||||
// Return the resized version to the composer/postData
|
||||
fileObj.url = file.appendToFileName(fileObj.url, '-resized');
|
||||
if (meta.config.resizeImageKeepOriginal) {
|
||||
fileObj.url = file.appendToFileName(fileObj.url, '-resized');
|
||||
}
|
||||
|
||||
return fileObj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user