fix: Allow subdomains upto 255 in self-hosted, closes #4524

This commit is contained in:
Tom Moor
2022-12-02 22:06:13 -05:00
parent 0f19a82488
commit 0a0498d139
5 changed files with 16 additions and 7 deletions

View File

@@ -24,6 +24,7 @@ import { CollectionPermission, TeamPreference } from "@shared/types";
import { getBaseDomain, RESERVED_SUBDOMAINS } from "@shared/utils/domains";
import env from "@server/env";
import DeleteAttachmentTask from "@server/queues/tasks/DeleteAttachmentTask";
import isCloudHosted from "@server/utils/isCloudHosted";
import parseAttachmentIds from "@server/utils/parseAttachmentIds";
import Attachment from "./Attachment";
import AuthenticationProvider from "./AuthenticationProvider";
@@ -66,8 +67,10 @@ class Team extends ParanoidModel {
@Unique
@Length({
min: 2,
max: 32,
msg: "subdomain must be between 2 and 32 characters",
max: isCloudHosted ? 32 : 255,
msg: `subdomain must be between 2 and ${
isCloudHosted ? 32 : 255
} characters`,
})
@Is({
args: [/^[a-z\d-]+$/, "i"],

View File

@@ -10,8 +10,8 @@ import {
BeforeCreate,
} from "sequelize-typescript";
import { TeamValidation } from "@shared/validations";
import env from "@server/env";
import { ValidationError } from "@server/errors";
import isCloudHosted from "@server/utils/isCloudHosted";
import Team from "./Team";
import User from "./User";
import IdModel from "./base/IdModel";
@@ -19,8 +19,6 @@ import Fix from "./decorators/Fix";
import IsFQDN from "./validators/IsFQDN";
import Length from "./validators/Length";
const isCloudHosted = env.DEPLOYMENT === "hosted";
@Table({ tableName: "team_domains", modelName: "team_domain" })
@Fix
class TeamDomain extends IdModel {