From ebb92cfa882c10e5506afaefdd5324587a678ced Mon Sep 17 00:00:00 2001 From: hmacr Date: Thu, 16 Jan 2025 07:43:14 +0530 Subject: [PATCH] remove namespace --- server/models/Attachment.ts | 2 -- server/models/Comment.ts | 2 -- server/models/Group.ts | 2 -- server/models/Pin.ts | 2 -- server/models/Share.ts | 2 -- server/models/Star.ts | 2 -- server/models/Subscription.ts | 2 -- server/models/base/Model.ts | 8 +++----- 8 files changed, 3 insertions(+), 19 deletions(-) diff --git a/server/models/Attachment.ts b/server/models/Attachment.ts index 07ad83c8b0..5b6baf5de2 100644 --- a/server/models/Attachment.ts +++ b/server/models/Attachment.ts @@ -36,8 +36,6 @@ class Attachment extends IdModel< InferAttributes, Partial> > { - static eventNamespace = "attachments"; - @Length({ max: 4096, msg: "key must be 4096 characters or less", diff --git a/server/models/Comment.ts b/server/models/Comment.ts index c860dcf379..c2a8cbf132 100644 --- a/server/models/Comment.ts +++ b/server/models/Comment.ts @@ -42,8 +42,6 @@ class Comment extends ParanoidModel< InferAttributes, Partial> > { - static eventNamespace = "comments"; - @TextLength({ max: CommentValidation.maxLength, msg: `Comment must be less than ${CommentValidation.maxLength} characters`, diff --git a/server/models/Group.ts b/server/models/Group.ts index 5d0d5f297b..dee4873bf1 100644 --- a/server/models/Group.ts +++ b/server/models/Group.ts @@ -60,8 +60,6 @@ class Group extends ParanoidModel< InferAttributes, Partial> > { - static eventNamespace = "groups"; - @Length({ min: 0, max: 255, msg: "name must be be 255 characters or less" }) @NotContainsUrl @Column diff --git a/server/models/Pin.ts b/server/models/Pin.ts index bebd850358..0234194a6a 100644 --- a/server/models/Pin.ts +++ b/server/models/Pin.ts @@ -20,8 +20,6 @@ class Pin extends IdModel< InferAttributes, Partial> > { - static eventNamespace = "pins"; - @Length({ max: 256, msg: `index must be 256 characters or less`, diff --git a/server/models/Share.ts b/server/models/Share.ts index c287d735ec..b3ef01e5ca 100644 --- a/server/models/Share.ts +++ b/server/models/Share.ts @@ -83,8 +83,6 @@ class Share extends IdModel< InferAttributes, Partial> > { - static eventNamespace = "shares"; - @Column published: boolean; diff --git a/server/models/Star.ts b/server/models/Star.ts index 585d3ca96c..2f71eb1bf8 100644 --- a/server/models/Star.ts +++ b/server/models/Star.ts @@ -19,8 +19,6 @@ class Star extends IdModel< InferAttributes, Partial> > { - static eventNamespace = "stars"; - @Length({ max: 256, msg: `index must be 256 characters or less`, diff --git a/server/models/Subscription.ts b/server/models/Subscription.ts index a24b7018b0..3b70a3a6b7 100644 --- a/server/models/Subscription.ts +++ b/server/models/Subscription.ts @@ -28,8 +28,6 @@ class Subscription extends ParanoidModel< InferAttributes, Partial> > { - static eventNamespace = "subscriptions"; - @BelongsTo(() => User, "userId") user: User; diff --git a/server/models/base/Model.ts b/server/models/base/Model.ts index e1d261cf68..8c89550a78 100644 --- a/server/models/base/Model.ts +++ b/server/models/base/Model.ts @@ -47,8 +47,7 @@ class Model< TCreationAttributes extends {} = TModelAttributes > extends SequelizeModel { /** - * The namespace to use for events, if none is provided an event will not be created - * during the migration period. In the future this may default to the table name. + * The namespace to use for events - defaults to the table name if none is provided. */ static eventNamespace: string | undefined; @@ -219,11 +218,10 @@ class Model< model: T, context: HookContext ) { - const namespace = this.eventNamespace; + const namespace = this.eventNamespace ?? this.tableName; const models = this.sequelize!.models; - // If no namespace is defined, don't create an event - if (!namespace || !context.event?.create) { + if (!context.event?.create) { return; }