|
|
|
@ -469,7 +469,10 @@ Flags.purge = async function (flagIds) {
|
|
|
|
|
const userFlags = flagData.filter(flagObj => flagObj.type === 'user');
|
|
|
|
|
const assignedFlags = flagData.filter(flagObj => !!flagObj.assignee);
|
|
|
|
|
|
|
|
|
|
const allReports = await db.getSortedSetsMembers(flagData.map(flagObj => `flag:${flagObj.flagId}:reports`));
|
|
|
|
|
const [allReports, postCids] = await Promise.all([
|
|
|
|
|
db.getSortedSetsMembers(flagData.map(flagObj => `flag:${flagObj.flagId}:reports`)),
|
|
|
|
|
posts.getCidsByPids(postFlags.map(flagObj => flagObj.targetId)),
|
|
|
|
|
]);
|
|
|
|
|
const allReporterUids = allReports.map(flagReports => flagReports.map(report => report && report.split(';')[0]));
|
|
|
|
|
const removeReporters = [];
|
|
|
|
|
flagData.forEach((flagObj, i) => {
|
|
|
|
@ -485,7 +488,7 @@ Flags.purge = async function (flagIds) {
|
|
|
|
|
...flagData.map(flagObj => ([`flags:byType:${flagObj.type}`, flagObj.flagId])),
|
|
|
|
|
...flagData.map(flagObj => ([`flags:byState:${flagObj.state}`, flagObj.flagId])),
|
|
|
|
|
...removeReporters,
|
|
|
|
|
...postFlags.map(flagObj => ([`flags:byCid:${flagObj.targetCid}`, flagObj.flagId])),
|
|
|
|
|
...postFlags.map((flagObj, i) => ([`flags:byCid:${postCids[i]}`, flagObj.flagId])),
|
|
|
|
|
...postFlags.map(flagObj => ([`flags:byPid:${flagObj.targetId}`, flagObj.flagId])),
|
|
|
|
|
...assignedFlags.map(flagObj => ([`flags:byAssignee:${flagObj.assignee}`, flagObj.flagId])),
|
|
|
|
|
...userFlags.map(flagObj => ([`flags:byTargetUid:${flagObj.targetUid}`, flagObj.flagId])),
|
|
|
|
|