Browse Source

fix: Re-add missing schemas type

Owen Diffey 1 year ago
parent
commit
306a21d3c6

+ 4 - 1
backend/src/modules/DataModule/models/abc/schema.ts

@@ -1,5 +1,8 @@
 import { Model, Schema, SchemaTypes, Types } from "mongoose";
-import { BaseSchema, TimestampsSchema } from "@/types/Schemas";
+import {
+	BaseSchema,
+	TimestampsSchema
+} from "@/modules/DataModule/types/Schemas";
 
 export interface AbcSchema extends Omit<BaseSchema, keyof TimestampsSchema> {
 	name: string;

+ 1 - 1
backend/src/modules/DataModule/models/news/schema.ts

@@ -7,7 +7,7 @@ import {
 	Types
 } from "mongoose";
 import { GetData } from "@/modules/DataModule/plugins/getData";
-import { BaseSchema } from "@/types/Schemas";
+import { BaseSchema } from "@/modules/DataModule/types/Schemas";
 import JobContext from "@/JobContext";
 import { NewsStatus } from "./NewsStatus";
 import config from "./config";

+ 1 - 1
backend/src/modules/DataModule/models/sessions/schema.ts

@@ -1,5 +1,5 @@
 import { Model, Schema, SchemaTypes, Types } from "mongoose";
-import { BaseSchema } from "@/types/Schemas";
+import { BaseSchema } from "@/modules/DataModule/types/Schemas";
 
 export interface SessionSchema extends BaseSchema {
 	userId: Types.ObjectId;

+ 1 - 1
backend/src/modules/DataModule/models/stations/schema.ts

@@ -1,6 +1,6 @@
 import { Model, Schema, SchemaTypes, Types } from "mongoose";
 import { GetData } from "@/modules/DataModule/plugins/getData";
-import { BaseSchema } from "@/types/Schemas";
+import { BaseSchema } from "@/modules/DataModule/types/Schemas";
 import { StationType } from "./StationType";
 import { StationPrivacy } from "./StationPrivacy";
 import { StationTheme } from "./StationTheme";

+ 1 - 1
backend/src/modules/DataModule/models/users/schema.ts

@@ -1,5 +1,5 @@
 import { Model, Schema, SchemaTypes, Types } from "mongoose";
-import { BaseSchema } from "@/types/Schemas";
+import { BaseSchema } from "@/modules/DataModule/types/Schemas";
 import config from "./config";
 import { UserRole } from "./UserRole";
 import { UserAvatarType } from "./UserAvatarType";

+ 12 - 0
backend/src/modules/DataModule/types/Schemas.ts

@@ -0,0 +1,12 @@
+import { Types } from "mongoose";
+import { DocumentVersion } from "@/modules/DataModule/plugins/documentVersion";
+
+// eslint-disable-next-line
+export interface BaseSchema extends DocumentVersion, TimestampsSchema {
+	_id: Types.ObjectId;
+}
+
+export interface TimestampsSchema {
+	createdAt: number;
+	updatedAt: number;
+}

+ 8 - 0
backend/src/modules/EventsModule.ts

@@ -133,6 +133,10 @@ export class EventsModule extends BaseModule {
 		await this._subClient.PSUBSCRIBE(
 			`__keyevent@${database}__:expired`,
 			async message => {
+				const type = message.substring(0, message.indexOf("."));
+
+				if (type !== "schedule") return;
+
 				const channel = message.substring(message.indexOf(".") + 1);
 
 				if (!this._scheduleCallbacks[channel]) return;
@@ -175,6 +179,10 @@ export class EventsModule extends BaseModule {
 	 * subscriptionListener - Listener for event subscriptions
 	 */
 	private async _subscriptionListener(message: string, key: string) {
+		const type = key.substring(0, key.indexOf("."));
+
+		if (type !== "event") return;
+
 		const channel = key.substring(key.indexOf(".") + 1);
 
 		if (message.startsWith("[") || message.startsWith("{"))