Skip to content

Commit

Permalink
Add titles to protection setting schemas. (#639)
Browse files Browse the repository at this point in the history
They are appearing as untitled when using the `protections show`
command.
  • Loading branch information
Gnuxie authored Dec 12, 2024
1 parent e73a823 commit ab2fb04
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
9 changes: 6 additions & 3 deletions src/protections/BasicFlooding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ const log = new Logger("BasicFloodingProtection");
export const DEFAULT_MAX_PER_MINUTE = 10;
const TIMESTAMP_THRESHOLD = 30000; // 30s out of phase

const BasicFloodingProtectionSettings = Type.Object({
maxPerMinute: Type.Integer({ default: DEFAULT_MAX_PER_MINUTE }),
});
const BasicFloodingProtectionSettings = Type.Object(
{
maxPerMinute: Type.Integer({ default: DEFAULT_MAX_PER_MINUTE }),
},
{ title: "BasicFloodingProtectionSettings" }
);
type BasicFloodingProtectionSettings = EDStatic<
typeof BasicFloodingProtectionSettings
>;
Expand Down
27 changes: 15 additions & 12 deletions src/protections/JoinWaveShortCircuit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,21 @@ const DEFAULT_MAX_PER_TIMESCALE = 50;
const DEFAULT_TIMESCALE_MINUTES = 60;
const ONE_MINUTE = 60_000; // 1min in ms

const JoinWaveShortCircuitProtectionSettings = Type.Object({
maxPer: Type.Integer({
default: DEFAULT_MAX_PER_TIMESCALE,
description:
"The maximum number of users that can join a room in the timescaleMinutes timescale before the room is set to invite-only.",
}),
timescaleMinutes: Type.Integer({
default: DEFAULT_TIMESCALE_MINUTES,
description:
"The timescale in minutes over which the maxPer users can join before the room is set to invite-only.",
}),
});
const JoinWaveShortCircuitProtectionSettings = Type.Object(
{
maxPer: Type.Integer({
default: DEFAULT_MAX_PER_TIMESCALE,
description:
"The maximum number of users that can join a room in the timescaleMinutes timescale before the room is set to invite-only.",
}),
timescaleMinutes: Type.Integer({
default: DEFAULT_TIMESCALE_MINUTES,
description:
"The timescale in minutes over which the maxPer users can join before the room is set to invite-only.",
}),
},
{ title: "JoinWaveShortCircuitProtectionSettings" }
);

type JoinWaveShortCircuitProtectionSettings = EDStatic<
typeof JoinWaveShortCircuitProtectionSettings
Expand Down
47 changes: 25 additions & 22 deletions src/protections/TrustedReporters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,31 @@ import { Type } from "@sinclair/typebox";

const MAX_REPORTED_EVENT_BACKLOG = 20;

const TrustedReportersProtectionSettings = Type.Object({
mxids: Type.Array(StringUserIDSchema, {
default: [],
uniqueItems: true,
description: "The users who are marked as trusted reporters.",
}),
alertThreshold: Type.Integer({
default: 3,
description:
"The number of reports from trusted reporters required before sending an alert to the management room.",
}),
redactThreshold: Type.Integer({
default: -1,
description:
"The number of reports from trusted reporters required before the relevant event is redacted.",
}),
banThreshold: Type.Integer({
default: -1,
description:
"The number of reports from trusted reporters required before the reported user banned.",
}),
});
const TrustedReportersProtectionSettings = Type.Object(
{
mxids: Type.Array(StringUserIDSchema, {
default: [],
uniqueItems: true,
description: "The users who are marked as trusted reporters.",
}),
alertThreshold: Type.Integer({
default: 3,
description:
"The number of reports from trusted reporters required before sending an alert to the management room.",
}),
redactThreshold: Type.Integer({
default: -1,
description:
"The number of reports from trusted reporters required before the relevant event is redacted.",
}),
banThreshold: Type.Integer({
default: -1,
description:
"The number of reports from trusted reporters required before the reported user banned.",
}),
},
{ title: "TrustedReportersProtectionSettings" }
);

type TrustedReportersProtectionSettings = EDStatic<
typeof TrustedReportersProtectionSettings
Expand Down

0 comments on commit ab2fb04

Please sign in to comment.