From f57464df300cef60914c3641dff1cc418eef9cf5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aaron=20D=C3=B6tsch?= <aaron@fsmpi.rwth-aachen.de>
Date: Sat, 5 Aug 2023 18:37:25 +0200
Subject: [PATCH] Move channelTypes.js from $lib to $lib/server

---
 src/lib/notifications/channelTypes.js        | 13 -------------
 src/lib/server/notifications/channelTypes.js | 13 +++++++++++++
 src/lib/server/notifications/handler.ts      |  2 +-
 src/routes/admin/user/[id]/+page.server.js   |  2 +-
 4 files changed, 15 insertions(+), 15 deletions(-)
 delete mode 100644 src/lib/notifications/channelTypes.js
 create mode 100644 src/lib/server/notifications/channelTypes.js

diff --git a/src/lib/notifications/channelTypes.js b/src/lib/notifications/channelTypes.js
deleted file mode 100644
index 766048e..0000000
--- a/src/lib/notifications/channelTypes.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import { handleWebhook } from "../server/notifications/webhookHandler";
-import { handleEmail } from "../server/notifications/emailHandler";
-
-/**
- * @type {{
- *  WEBHOOK: import("./types").ChannelType<?>,
- *  EMAIL: import("./types").ChannelType<?>
- * }}
- */
-export const ChannelType = {
-	WEBHOOK: {key: 1<<0, handler: handleWebhook},
-	EMAIL: {key: 1<<1, handler: handleEmail},
-};
diff --git a/src/lib/server/notifications/channelTypes.js b/src/lib/server/notifications/channelTypes.js
new file mode 100644
index 0000000..90df94f
--- /dev/null
+++ b/src/lib/server/notifications/channelTypes.js
@@ -0,0 +1,13 @@
+import { handleWebhook } from "./webhookHandler";
+import { handleEmail } from "./emailHandler";
+
+/**
+ * @type {{
+ *  WEBHOOK: import("../../notifications/types").ChannelType<?>,
+ *  EMAIL: import("../../notifications/types").ChannelType<?>
+ * }}
+ */
+export const ChannelType = {
+	WEBHOOK: {key: 1<<0, handler: handleWebhook},
+	EMAIL: {key: 1<<1, handler: handleEmail},
+};
diff --git a/src/lib/server/notifications/handler.ts b/src/lib/server/notifications/handler.ts
index 0ca34a4..07c8337 100644
--- a/src/lib/server/notifications/handler.ts
+++ b/src/lib/server/notifications/handler.ts
@@ -1,5 +1,5 @@
 import { db } from "$lib/server/database";
-import { ChannelType } from "../../notifications/channelTypes";
+import { ChannelType } from "./channelTypes";
 import type { HandlerReturnType, NotificationChannel, NotificationData, NotificationType, PossibleNotificationType } from "../../notifications/types";
 
 export async function sendNotification<T extends PossibleNotificationType>(user: { id: number, notificationChannels: NotificationChannel[] | undefined } | number, type: NotificationType<T>, data: NotificationData<T>): Promise<HandlerReturnType[]>{
diff --git a/src/routes/admin/user/[id]/+page.server.js b/src/routes/admin/user/[id]/+page.server.js
index 654a367..6d438b4 100644
--- a/src/routes/admin/user/[id]/+page.server.js
+++ b/src/routes/admin/user/[id]/+page.server.js
@@ -1,7 +1,7 @@
 import { addUserCard, getUser, updateCard } from "../../api/users";
 import { fail } from "@sveltejs/kit";
 import { createTransaction } from "../../api/transactions";
-import { ChannelType } from "$lib/notifications/channelTypes";
+import { ChannelType } from "$lib/server/notifications/channelTypes";
 import { createNotificationChannel, updateNotificationChannel } from "../../api/notificationChannels";
 
 export const load = async ({ params }) => {
-- 
GitLab