mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: support rescinding user flags
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
"chat-with": "Continue chat with %1",
|
||||
"new-chat-with": "Start new chat with %1",
|
||||
"flag-profile": "Flag Profile",
|
||||
"profile-flagged": "Already flagged",
|
||||
"follow": "Follow",
|
||||
"unfollow": "Unfollow",
|
||||
"more": "More",
|
||||
|
||||
@@ -56,6 +56,7 @@ define('forum/account/header', [
|
||||
components.get('account/delete-content').on('click', () => AccountsDelete.content(ajaxify.data.theirid));
|
||||
components.get('account/delete-all').on('click', () => AccountsDelete.purge(ajaxify.data.theirid));
|
||||
components.get('account/flag').on('click', flagAccount);
|
||||
components.get('account/already-flagged').on('click', rescindAccountFlag);
|
||||
components.get('account/block').on('click', () => toggleBlockAccount('block'));
|
||||
components.get('account/unblock').on('click', () => toggleBlockAccount('unblock'));
|
||||
};
|
||||
@@ -130,6 +131,18 @@ define('forum/account/header', [
|
||||
});
|
||||
}
|
||||
|
||||
function rescindAccountFlag() {
|
||||
const flagId = $(this).data('flag-id')
|
||||
require(['flags'], function (flags) {
|
||||
bootbox.confirm('[[flags:modal-confirm-rescind]]', function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
flags.rescind(flagId);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function toggleBlockAccount(action) {
|
||||
socket.emit('user.toggleBlock', {
|
||||
blockeeUid: ajaxify.data.uid,
|
||||
|
||||
@@ -15,6 +15,7 @@ const messaging = require('../../messaging');
|
||||
const categories = require('../../categories');
|
||||
const posts = require('../../posts');
|
||||
const activitypub = require('../../activitypub');
|
||||
const flags = require('../../flags');
|
||||
|
||||
const relative_path = nconf.get('relative_path');
|
||||
|
||||
@@ -26,7 +27,12 @@ helpers.getUserDataByUserSlug = async function (userslug, callerUID, query = {})
|
||||
return null;
|
||||
}
|
||||
|
||||
const results = await getAllData(uid, callerUID);
|
||||
const [results, canFlag, flagged, flagId] = await Promise.all([
|
||||
getAllData(uid, callerUID),
|
||||
privileges.users.canFlag(callerUID, uid),
|
||||
flags.exists('user', uid, callerUID),
|
||||
flags.getFlagIdByTarget('user', uid),
|
||||
]);
|
||||
if (!results.userData) {
|
||||
throw new Error('[[error:invalid-uid]]');
|
||||
}
|
||||
@@ -80,7 +86,9 @@ helpers.getUserDataByUserSlug = async function (userslug, callerUID, query = {})
|
||||
userData.canEdit = results.canEdit;
|
||||
userData.canBan = results.canBanUser;
|
||||
userData.canMute = results.canMuteUser;
|
||||
userData.canFlag = (await privileges.users.canFlag(callerUID, userData.uid)).flag;
|
||||
userData.canFlag = canFlag.flag;
|
||||
userData.flagged = flagged;
|
||||
userData.flagId = flagId;
|
||||
userData.canChangePassword = isAdmin || (isSelf && !meta.config['password:disableEdit']);
|
||||
userData.isSelf = isSelf;
|
||||
userData.isFollowing = results.isFollowing;
|
||||
|
||||
Reference in New Issue
Block a user