Limit account settings length

This commit is contained in:
Terncode committed 2026-11-17 20:33:58 +01:00
1 parent 46c944b0ae
commit 566a0d64cc
1 file changed
+9 -4
+9 -4
View File
@@ -1,5 +1,7 @@
import { formatDistanceToNow } from 'date-fns';
import { ACCOUNT_NAME_MAX_LENGTH, ACCOUNT_NAME_MIN_LENGTH, MIN_CHATLOG_RANGE, MAX_CHATLOG_RANGE, HIDES_PER_PAGE } from '../../common/constants';
import {
ACCOUNT_NAME_MAX_LENGTH, ACCOUNT_NAME_MIN_LENGTH, MIN_CHATLOG_RANGE, MAX_CHATLOG_RANGE, HIDES_PER_PAGE, MAX_FILTER_WORDS_LENGTH
} from '../../common/constants';
import {
UpdateAccountData, AccountSettings, AccountData, ModAction, EntitiesEditorInfo, EntityNameTypes
} from '../../common/interfaces';
@@ -22,6 +24,9 @@ export type UpdateSettings = ReturnType<typeof createUpdateSettings>;
export type RemoveSite = ReturnType<typeof createRemoveSite>;
export type GetAccountData = ReturnType<typeof createGetAccountData>;
const MAX_DEFAULT_SERVER_LENGTH = 100;
const MAX_ACTIONS_SETTING_LENGTH = 20000;
type LogAccount = (accountId: ID, message: string) => void;
const exclude = [
@@ -83,7 +88,7 @@ function fixAccountSettings(settings: AccountSettings | undefined) {
const fixed: Partial<AccountSettings> = {};
if (settings) {
if (settings.defaultServer !== undefined) {
if (settings.defaultServer !== undefined && `${settings.defaultServer}`.length <= MAX_DEFAULT_SERVER_LENGTH) {
fixed.defaultServer = `${settings.defaultServer}`;
}
@@ -124,10 +129,10 @@ function fixAccountSettings(settings: AccountSettings | undefined) {
}
if (settings.filterWords !== undefined) {
fixed.filterWords = `${settings.filterWords}`;
fixed.filterWords = `${settings.filterWords}`.substr(0, MAX_FILTER_WORDS_LENGTH);
}
if (settings.actions !== undefined) {
if (settings.actions !== undefined && `${settings.actions}`.length <= MAX_ACTIONS_SETTING_LENGTH) {
fixed.actions = `${settings.actions}`;
}