mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 04:55:42 +09:00
fix(admin): save premium limits and model changes (#3386)
This commit is contained in:
1 parent
7d2c51a57f
commit
6acd7f3d22
18 files changed
+1035
-59
No files matched your search
@@ -1,5 +1,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {MAX_BIO_LENGTH} from '@fluxer/constants/src/LimitConstants';
|
||||
|
||||
export const LIMIT_KEYS = [
|
||||
'avatar_max_size',
|
||||
'emoji_max_size',
|
||||
@@ -399,6 +401,8 @@ export const LIMIT_KEY_METADATA: Record<LimitKey, LimitKeyMetadata> = {
|
||||
scope: 'user',
|
||||
isToggle: false,
|
||||
unit: 'count',
|
||||
min: 0,
|
||||
max: MAX_BIO_LENGTH,
|
||||
},
|
||||
max_bookmarks: {
|
||||
key: 'max_bookmarks',
|
||||
|
||||
@@ -6,7 +6,8 @@ import {
|
||||
SystemChannelFlags,
|
||||
SystemChannelFlagsDescriptions,
|
||||
} from '@fluxer/constants/src/GuildConstants';
|
||||
import {LIMIT_KEYS} from '@fluxer/constants/src/LimitConfigMetadata';
|
||||
import {LIMIT_KEY_METADATA, LIMIT_KEYS} from '@fluxer/constants/src/LimitConfigMetadata';
|
||||
import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes';
|
||||
import {ADMIN_ACL_COUNT, AdminAclType} from '@fluxer/schema/src/domains/admin/AdminAclType';
|
||||
import {AdminArchiveResponseSchema} from '@fluxer/schema/src/domains/admin/AdminArchiveSchemas';
|
||||
import {GuildAdminResponse} from '@fluxer/schema/src/domains/admin/AdminGuildSchemas';
|
||||
@@ -916,6 +917,20 @@ const LimitRuleSchema = z.object({
|
||||
},
|
||||
{error: 'Invalid limit key detected'},
|
||||
)
|
||||
.superRefine((limits, ctx) => {
|
||||
for (const key of LIMIT_KEYS) {
|
||||
const value = limits[key];
|
||||
const {min = 0, max} = LIMIT_KEY_METADATA[key];
|
||||
if (value !== undefined && max !== undefined && (value < min || value > max)) {
|
||||
ctx.addIssue({
|
||||
code: 'custom',
|
||||
message: ValidationErrorCodes.VALUE_MUST_BE_INTEGER_IN_RANGE,
|
||||
params: {minValue: min, maxValue: max},
|
||||
path: [key],
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.describe('Per-limit key values'),
|
||||
});
|
||||
const LimitConfigSchema = z.object({
|
||||
|
||||
Reference in new issue
Block a user