automod: fix logs showing duplicate users
This commit is contained in:
parent
e7d647f1e6
commit
b6b4154b2d
1 changed files with 4 additions and 2 deletions
|
@ -2,14 +2,16 @@ import * as t from "io-ts";
|
||||||
import { automodAction } from "../helpers";
|
import { automodAction } from "../helpers";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||||
import { LogType } from "../../../data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { stripObjectToScalars } from "../../../utils";
|
import { stripObjectToScalars, unique } from "../../../utils";
|
||||||
|
|
||||||
export const LogAction = automodAction({
|
export const LogAction = automodAction({
|
||||||
configType: t.boolean,
|
configType: t.boolean,
|
||||||
defaultConfig: true,
|
defaultConfig: true,
|
||||||
|
|
||||||
async apply({ pluginData, contexts, ruleName, matchResult }) {
|
async apply({ pluginData, contexts, ruleName, matchResult }) {
|
||||||
const safeUsers = contexts.map(c => c.user && stripObjectToScalars(c.user)).filter(Boolean);
|
const safeUsers = unique(contexts.map(c => c.user))
|
||||||
|
.filter(Boolean)
|
||||||
|
.map(user => stripObjectToScalars(user));
|
||||||
const safeUser = safeUsers[0];
|
const safeUser = safeUsers[0];
|
||||||
const actionsTaken = Object.keys(pluginData.config.get().rules[ruleName].actions).join(", ");
|
const actionsTaken = Object.keys(pluginData.config.get().rules[ruleName].actions).join(", ");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue