mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 10:35:55 +01:00
feat: closes #12490, show profile flags on account info page
This commit is contained in:
@@ -103,10 +103,10 @@
|
|||||||
"nodebb-plugin-ntfy": "1.7.4",
|
"nodebb-plugin-ntfy": "1.7.4",
|
||||||
"nodebb-plugin-spam-be-gone": "2.2.2",
|
"nodebb-plugin-spam-be-gone": "2.2.2",
|
||||||
"nodebb-rewards-essentials": "1.0.0",
|
"nodebb-rewards-essentials": "1.0.0",
|
||||||
"nodebb-theme-harmony": "1.2.51",
|
"nodebb-theme-harmony": "1.2.52",
|
||||||
"nodebb-theme-lavender": "7.1.8",
|
"nodebb-theme-lavender": "7.1.8",
|
||||||
"nodebb-theme-peace": "2.2.4",
|
"nodebb-theme-peace": "2.2.4",
|
||||||
"nodebb-theme-persona": "13.3.16",
|
"nodebb-theme-persona": "13.3.17",
|
||||||
"nodebb-widget-essentials": "7.0.15",
|
"nodebb-widget-essentials": "7.0.15",
|
||||||
"nodemailer": "6.9.13",
|
"nodemailer": "6.9.13",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
|
|||||||
@@ -90,6 +90,6 @@
|
|||||||
"bulk-actions": "Bulk Actions",
|
"bulk-actions": "Bulk Actions",
|
||||||
"bulk-resolve": "Resolve Flag(s)",
|
"bulk-resolve": "Resolve Flag(s)",
|
||||||
"bulk-success": "%1 flags updated",
|
"bulk-success": "%1 flags updated",
|
||||||
"flagged-timeago-readable": "Flagged <span class=\"timeago\" title=\"%1\"></span> (%2)",
|
"flagged-timeago": "Flagged <span class=\"timeago\" title=\"%1\"></span>",
|
||||||
"auto-flagged": "[Auto Flagged] Received %1 downvotes."
|
"auto-flagged": "[Auto Flagged] Received %1 downvotes."
|
||||||
}
|
}
|
||||||
@@ -181,6 +181,10 @@
|
|||||||
"sso.dissociate-confirm": "Are you sure you wish to dissociate your account from %1?",
|
"sso.dissociate-confirm": "Are you sure you wish to dissociate your account from %1?",
|
||||||
|
|
||||||
"info.latest-flags": "Latest Flags",
|
"info.latest-flags": "Latest Flags",
|
||||||
|
"info.profile": "Profile",
|
||||||
|
"info.post": "Post",
|
||||||
|
"info.view-flag": "View flag",
|
||||||
|
"info.reported-by": "Reported by:",
|
||||||
"info.no-flags": "No Flagged Posts Found",
|
"info.no-flags": "No Flagged Posts Found",
|
||||||
"info.ban-history": "Recent Ban History",
|
"info.ban-history": "Recent Ban History",
|
||||||
"info.no-ban-history": "This user has never been banned",
|
"info.no-ban-history": "This user has never been banned",
|
||||||
|
|||||||
@@ -914,7 +914,7 @@ Flags.notify = async function (flagObj, uid, notifySelf = false) {
|
|||||||
});
|
});
|
||||||
uids = uids.concat(modUids[0]);
|
uids = uids.concat(modUids[0]);
|
||||||
} else if (flagObj.type === 'user') {
|
} else if (flagObj.type === 'user') {
|
||||||
const targetDisplayname = flagObj.target && flagObj.target.user ? flagObj.target.user.displayname : '[[global:guest]]';
|
const targetDisplayname = flagObj.target && flagObj.target.displayname ? flagObj.target.displayname : '[[global:guest]]';
|
||||||
notifObj = await notifications.create({
|
notifObj = await notifications.create({
|
||||||
type: 'new-user-flag',
|
type: 'new-user-flag',
|
||||||
bodyShort: `[[notifications:user-flagged-user, ${displayname}, ${targetDisplayname}]]`,
|
bodyShort: `[[notifications:user-flagged-user, ${displayname}, ${targetDisplayname}]]`,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const db = require('../database');
|
|||||||
const posts = require('../posts');
|
const posts = require('../posts');
|
||||||
const topics = require('../topics');
|
const topics = require('../topics');
|
||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
|
const Flags = require('../flags');
|
||||||
|
|
||||||
module.exports = function (User) {
|
module.exports = function (User) {
|
||||||
User.getLatestBanInfo = async function (uid) {
|
User.getLatestBanInfo = async function (uid) {
|
||||||
@@ -40,24 +41,11 @@ module.exports = function (User) {
|
|||||||
], 0, 19),
|
], 0, 19),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Get pids from flag objects
|
|
||||||
const keys = flags.map(flagObj => `flag:${flagObj.value}`);
|
const keys = flags.map(flagObj => `flag:${flagObj.value}`);
|
||||||
const payload = await db.getObjectsFields(keys, ['type', 'targetId']);
|
const payload = await db.getObjectsFields(keys, ['flagId', 'type', 'targetId', 'datetime']);
|
||||||
|
|
||||||
// Only pass on flag ids from posts
|
|
||||||
flags = payload.reduce((memo, cur, idx) => {
|
|
||||||
if (cur.type === 'post') {
|
|
||||||
memo.push({
|
|
||||||
value: parseInt(cur.targetId, 10),
|
|
||||||
score: flags[idx].score,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return memo;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
[flags, bans, mutes] = await Promise.all([
|
[flags, bans, mutes] = await Promise.all([
|
||||||
getFlagMetadata(flags),
|
getFlagMetadata(payload),
|
||||||
formatBanMuteData(bans, '[[user:info.banned-no-reason]]'),
|
formatBanMuteData(bans, '[[user:info.banned-no-reason]]'),
|
||||||
formatBanMuteData(mutes, '[[user:info.muted-no-reason]]'),
|
formatBanMuteData(mutes, '[[user:info.muted-no-reason]]'),
|
||||||
]);
|
]);
|
||||||
@@ -81,18 +69,23 @@ module.exports = function (User) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function getFlagMetadata(flags) {
|
async function getFlagMetadata(flags) {
|
||||||
const pids = flags.map(flagObj => parseInt(flagObj.value, 10));
|
const postFlags = flags.filter(flag => flag && flag.type === 'post');
|
||||||
|
const reports = await Promise.all(flags.map(flag => Flags.getReports(flag.flagId)));
|
||||||
|
|
||||||
|
flags.forEach((flag, idx) => {
|
||||||
|
if (flag) {
|
||||||
|
flag.timestampISO = new Date(flag.datetime).toISOString();
|
||||||
|
flag.reports = reports[idx];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const pids = postFlags.map(flagObj => parseInt(flagObj.targetId, 10));
|
||||||
const postData = await posts.getPostsFields(pids, ['tid']);
|
const postData = await posts.getPostsFields(pids, ['tid']);
|
||||||
const tids = postData.map(post => post.tid);
|
const tids = postData.map(post => post.tid);
|
||||||
|
|
||||||
const topicData = await topics.getTopicsFields(tids, ['title']);
|
const topicData = await topics.getTopicsFields(tids, ['title']);
|
||||||
flags = flags.map((flagObj, idx) => {
|
postFlags.forEach((flagObj, idx) => {
|
||||||
flagObj.pid = flagObj.value;
|
flagObj.pid = flagObj.targetId;
|
||||||
flagObj.timestamp = flagObj.score;
|
|
||||||
flagObj.timestampISO = new Date(flagObj.score).toISOString();
|
|
||||||
|
|
||||||
delete flagObj.value;
|
|
||||||
delete flagObj.score;
|
|
||||||
if (!tids[idx]) {
|
if (!tids[idx]) {
|
||||||
flagObj.targetPurged = true;
|
flagObj.targetPurged = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user