mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-23 02:51:13 +02:00
refactor: flags detail page
- Show account moderation history
- Ban and delete quick actions
Squashed commit of the following:
commit 0e782e65f4d48ae814708e510ec9d01bcdd914e0
Author: Julian Lam <julian@nodebb.org>
Date: Tue May 26 20:24:53 2020 -0400
fix(deps): use persona 10.1.41/vanilla 11.1.17
commit 369e073d3c3189d8ce181eb3d573489cbe54d4fc
Author: Julian Lam <julian@nodebb.org>
Date: Tue May 26 20:23:24 2020 -0400
fix: allow ban and delete exported methods to have cbs
commit b83a086ea31a77ec82d161306c0b9bc115cb2a3a
Merge: 525aae1ea 256ee45d3
Author: Julian Lam <julian@nodebb.org>
Date: Tue May 26 08:54:25 2020 -0400
Merge remote-tracking branch 'origin/master' into flags-improvements
commit 525aae1ea2e5d0103028a0f0c8dde05f172d088e
Author: Julian Lam <julian@nodebb.org>
Date: Tue May 26 08:53:39 2020 -0400
feat: integrate ban history and username changes to flag history list
commit 3e68ad28ba266f4c8620a676aa7f463f0a9d1df7
Author: Julian Lam <julian@nodebb.org>
Date: Mon May 25 18:22:53 2020 -0400
feat: allow ban and deletion from flag details page
commit a559ea1d8e8883385c2876868d855a0b93516c54
Author: Julian Lam <julian@nodebb.org>
Date: Mon May 25 18:22:00 2020 -0400
feat: export banAccount and deleteAccount methods from accounts module
This commit is contained in:
68
src/flags.js
68
src/flags.js
@@ -432,6 +432,8 @@ Flags.update = async function (flagId, uid, changeset) {
|
||||
Flags.getHistory = async function (flagId) {
|
||||
const uids = [];
|
||||
let history = await db.getSortedSetRevRangeWithScores('flag:' + flagId + ':history', 0, -1);
|
||||
const flagData = await db.getObjectFields('flag:' + flagId, ['type', 'targetId']);
|
||||
const targetUid = await Flags.getTargetUid(flagData.type, flagData.targetId);
|
||||
|
||||
history = history.map(function (entry) {
|
||||
entry.value = JSON.parse(entry.value);
|
||||
@@ -451,8 +453,74 @@ Flags.getHistory = async function (flagId) {
|
||||
datetimeISO: utils.toISOString(entry.score),
|
||||
};
|
||||
});
|
||||
|
||||
// Append ban history and username change data
|
||||
let recentBans = await db.getSortedSetRevRange('uid:' + targetUid + ':bans:timestamp', 0, 19);
|
||||
const usernameChanges = await user.getHistory('user:' + targetUid + ':usernames');
|
||||
const emailChanges = await user.getHistory('user:' + targetUid + ':emails');
|
||||
|
||||
recentBans = await db.getObjects(recentBans);
|
||||
history = history.concat(recentBans.reduce((memo, cur) => {
|
||||
uids.push(cur.fromUid);
|
||||
memo.push({
|
||||
uid: cur.fromUid,
|
||||
meta: [
|
||||
{
|
||||
key: '[[user:banned]]',
|
||||
value: cur.reason,
|
||||
labelClass: 'danger',
|
||||
},
|
||||
{
|
||||
key: '[[user:info.banned-expiry]]',
|
||||
value: new Date(parseInt(cur.expire, 10)).toISOString(),
|
||||
labelClass: 'default',
|
||||
},
|
||||
],
|
||||
datetime: parseInt(cur.timestamp, 10),
|
||||
datetimeISO: utils.toISOString(parseInt(cur.timestamp, 10)),
|
||||
});
|
||||
|
||||
return memo;
|
||||
}, [])).concat(usernameChanges.reduce((memo, changeObj) => {
|
||||
uids.push(targetUid);
|
||||
memo.push({
|
||||
uid: targetUid,
|
||||
meta: [
|
||||
{
|
||||
key: '[[user:change_username]]',
|
||||
value: changeObj.value,
|
||||
labelClass: 'primary',
|
||||
},
|
||||
],
|
||||
datetime: changeObj.timestamp,
|
||||
datetimeISO: changeObj.timestampISO,
|
||||
});
|
||||
|
||||
return memo;
|
||||
}, [])).concat(emailChanges.reduce((memo, changeObj) => {
|
||||
uids.push(targetUid);
|
||||
memo.push({
|
||||
uid: targetUid,
|
||||
meta: [
|
||||
{
|
||||
key: '[[user:change_email]]',
|
||||
value: changeObj.value,
|
||||
labelClass: 'primary',
|
||||
},
|
||||
],
|
||||
datetime: changeObj.timestamp,
|
||||
datetimeISO: changeObj.timestampISO,
|
||||
});
|
||||
|
||||
return memo;
|
||||
}, []));
|
||||
|
||||
const userData = await user.getUsersFields(uids, ['username', 'userslug', 'picture']);
|
||||
history.forEach((event, idx) => { event.user = userData[idx]; });
|
||||
|
||||
// Resort by date
|
||||
history = history.sort((a, b) => b.datetime - a.datetime);
|
||||
|
||||
return history;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user