mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 02:25: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-spam-be-gone": "2.2.2",
|
||||
"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-peace": "2.2.4",
|
||||
"nodebb-theme-persona": "13.3.16",
|
||||
"nodebb-theme-persona": "13.3.17",
|
||||
"nodebb-widget-essentials": "7.0.15",
|
||||
"nodemailer": "6.9.13",
|
||||
"nprogress": "0.2.0",
|
||||
|
||||
@@ -90,6 +90,6 @@
|
||||
"bulk-actions": "Bulk Actions",
|
||||
"bulk-resolve": "Resolve Flag(s)",
|
||||
"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."
|
||||
}
|
||||
@@ -181,6 +181,10 @@
|
||||
"sso.dissociate-confirm": "Are you sure you wish to dissociate your account from %1?",
|
||||
|
||||
"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.ban-history": "Recent Ban History",
|
||||
"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]);
|
||||
} 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({
|
||||
type: 'new-user-flag',
|
||||
bodyShort: `[[notifications:user-flagged-user, ${displayname}, ${targetDisplayname}]]`,
|
||||
|
||||
@@ -7,6 +7,7 @@ const db = require('../database');
|
||||
const posts = require('../posts');
|
||||
const topics = require('../topics');
|
||||
const utils = require('../utils');
|
||||
const Flags = require('../flags');
|
||||
|
||||
module.exports = function (User) {
|
||||
User.getLatestBanInfo = async function (uid) {
|
||||
@@ -40,24 +41,11 @@ module.exports = function (User) {
|
||||
], 0, 19),
|
||||
]);
|
||||
|
||||
// Get pids from flag objects
|
||||
const keys = flags.map(flagObj => `flag:${flagObj.value}`);
|
||||
const payload = await db.getObjectsFields(keys, ['type', 'targetId']);
|
||||
|
||||
// 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;
|
||||
}, []);
|
||||
const payload = await db.getObjectsFields(keys, ['flagId', 'type', 'targetId', 'datetime']);
|
||||
|
||||
[flags, bans, mutes] = await Promise.all([
|
||||
getFlagMetadata(flags),
|
||||
getFlagMetadata(payload),
|
||||
formatBanMuteData(bans, '[[user:info.banned-no-reason]]'),
|
||||
formatBanMuteData(mutes, '[[user:info.muted-no-reason]]'),
|
||||
]);
|
||||
@@ -81,18 +69,23 @@ module.exports = function (User) {
|
||||
};
|
||||
|
||||
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 tids = postData.map(post => post.tid);
|
||||
|
||||
const topicData = await topics.getTopicsFields(tids, ['title']);
|
||||
flags = flags.map((flagObj, idx) => {
|
||||
flagObj.pid = flagObj.value;
|
||||
flagObj.timestamp = flagObj.score;
|
||||
flagObj.timestampISO = new Date(flagObj.score).toISOString();
|
||||
|
||||
delete flagObj.value;
|
||||
delete flagObj.score;
|
||||
postFlags.forEach((flagObj, idx) => {
|
||||
flagObj.pid = flagObj.targetId;
|
||||
if (!tids[idx]) {
|
||||
flagObj.targetPurged = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user