diff --git a/drizzle/0000_amusing_shatterstar.sql b/drizzle/0000_amusing_shatterstar.sql
new file mode 100644
index 0000000..bdf1ba3
--- /dev/null
+++ b/drizzle/0000_amusing_shatterstar.sql
@@ -0,0 +1,74 @@
+CREATE TABLE `channel` (
+ `id` text PRIMARY KEY NOT NULL,
+ `name` text NOT NULL,
+ `server_id` text NOT NULL,
+ `messages` text DEFAULT '[]' NOT NULL,
+ FOREIGN KEY (`server_id`) REFERENCES `server`(`id`) ON UPDATE no action ON DELETE no action
+);
+--> statement-breakpoint
+CREATE TABLE `directMessage` (
+ `id` text PRIMARY KEY NOT NULL,
+ `first_member` text NOT NULL,
+ `second_member` text NOT NULL,
+ `messages` text DEFAULT '[]' NOT NULL,
+ FOREIGN KEY (`first_member`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
+ FOREIGN KEY (`second_member`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
+);
+--> statement-breakpoint
+CREATE TABLE `friendRequest` (
+ `id` text PRIMARY KEY NOT NULL,
+ `from_user` text NOT NULL,
+ `from_username` text NOT NULL,
+ `to_username` text NOT NULL,
+ `to_user` text NOT NULL,
+ FOREIGN KEY (`from_user`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
+ FOREIGN KEY (`from_username`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
+ FOREIGN KEY (`to_username`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
+ FOREIGN KEY (`to_user`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
+);
+--> statement-breakpoint
+CREATE TABLE `group` (
+ `id` text PRIMARY KEY NOT NULL,
+ `name` text NOT NULL,
+ `owner` text NOT NULL,
+ `members` text DEFAULT '[]' NOT NULL,
+ `messages` text DEFAULT '[]' NOT NULL,
+ FOREIGN KEY (`owner`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
+);
+--> statement-breakpoint
+CREATE TABLE `invite` (
+ `id` text PRIMARY KEY NOT NULL,
+ `server_id` text NOT NULL,
+ `code` text NOT NULL,
+ FOREIGN KEY (`server_id`) REFERENCES `server`(`id`) ON UPDATE no action ON DELETE no action
+);
+--> statement-breakpoint
+CREATE TABLE `server` (
+ `id` text PRIMARY KEY NOT NULL,
+ `name` text NOT NULL,
+ `owner` text NOT NULL,
+ `members` text DEFAULT '[]' NOT NULL,
+ `channels` text DEFAULT '[]' NOT NULL,
+ FOREIGN KEY (`owner`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
+);
+--> statement-breakpoint
+CREATE TABLE `session` (
+ `id` text PRIMARY KEY NOT NULL,
+ `user_id` text NOT NULL,
+ `expires_at` integer NOT NULL,
+ FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
+);
+--> statement-breakpoint
+CREATE TABLE `user` (
+ `id` text PRIMARY KEY NOT NULL,
+ `username` text NOT NULL,
+ `email` text NOT NULL,
+ `password_hash` text NOT NULL,
+ `status_overwrite` integer DEFAULT 3 NOT NULL,
+ `friends` text DEFAULT '[]' NOT NULL,
+ `servers` text DEFAULT '[]' NOT NULL,
+ `groups` text DEFAULT '[]' NOT NULL
+);
+--> statement-breakpoint
+CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`);--> statement-breakpoint
+CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);
\ No newline at end of file
diff --git a/drizzle/0000_hard_thaddeus_ross.sql b/drizzle/0000_hard_thaddeus_ross.sql
deleted file mode 100644
index 5b08e55..0000000
--- a/drizzle/0000_hard_thaddeus_ross.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-CREATE TABLE `session` (
- `id` text PRIMARY KEY NOT NULL,
- `user_id` text NOT NULL,
- `expires_at` integer NOT NULL,
- FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
-);
---> statement-breakpoint
-CREATE TABLE `user` (
- `id` text PRIMARY KEY NOT NULL,
- `age` integer,
- `username` text NOT NULL,
- `password_hash` text NOT NULL
-);
---> statement-breakpoint
-CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`);
\ No newline at end of file
diff --git a/drizzle/0001_melted_goliath.sql b/drizzle/0001_melted_goliath.sql
deleted file mode 100644
index f35bca2..0000000
--- a/drizzle/0001_melted_goliath.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE `user` ADD `email` text NOT NULL;--> statement-breakpoint
-CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);
\ No newline at end of file
diff --git a/drizzle/0002_fair_sasquatch.sql b/drizzle/0002_fair_sasquatch.sql
deleted file mode 100644
index ba772e5..0000000
--- a/drizzle/0002_fair_sasquatch.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE `user` ADD `friends` text DEFAULT '[]' NOT NULL;
\ No newline at end of file
diff --git a/drizzle/0003_wise_lucky_pierre.sql b/drizzle/0003_wise_lucky_pierre.sql
deleted file mode 100644
index b387f5a..0000000
--- a/drizzle/0003_wise_lucky_pierre.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-CREATE TABLE `group` (
- `id` text PRIMARY KEY NOT NULL,
- `name` text NOT NULL,
- `owner` text NOT NULL,
- `members` text DEFAULT '[]' NOT NULL,
- FOREIGN KEY (`owner`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
-);
---> statement-breakpoint
-CREATE TABLE `server` (
- `id` text PRIMARY KEY NOT NULL,
- `name` text NOT NULL,
- `owner` text NOT NULL,
- `members` text DEFAULT '[]' NOT NULL,
- `channels` text DEFAULT '[]' NOT NULL,
- FOREIGN KEY (`owner`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
-);
---> statement-breakpoint
-ALTER TABLE `user` DROP COLUMN `age`;
\ No newline at end of file
diff --git a/drizzle/0004_fair_stature.sql b/drizzle/0004_fair_stature.sql
deleted file mode 100644
index 03d602c..0000000
--- a/drizzle/0004_fair_stature.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE `user` ADD `servers` text DEFAULT '[]' NOT NULL;--> statement-breakpoint
-ALTER TABLE `user` ADD `groups` text DEFAULT '[]' NOT NULL;
\ No newline at end of file
diff --git a/drizzle/0005_mute_mephisto.sql b/drizzle/0005_mute_mephisto.sql
deleted file mode 100644
index 7669217..0000000
--- a/drizzle/0005_mute_mephisto.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE `channel` (
- `id` text PRIMARY KEY NOT NULL,
- `name` text NOT NULL,
- `server_id` text NOT NULL,
- `messages` text DEFAULT '[]' NOT NULL,
- FOREIGN KEY (`server_id`) REFERENCES `server`(`id`) ON UPDATE no action ON DELETE no action
-);
diff --git a/drizzle/0006_gifted_machine_man.sql b/drizzle/0006_gifted_machine_man.sql
deleted file mode 100644
index 6f24705..0000000
--- a/drizzle/0006_gifted_machine_man.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE `friendRequest` (
- `id` text PRIMARY KEY NOT NULL,
- `from_user` text NOT NULL,
- `to_user` text NOT NULL,
- FOREIGN KEY (`from_user`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
- FOREIGN KEY (`to_user`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
-);
diff --git a/drizzle/0007_outstanding_punisher.sql b/drizzle/0007_outstanding_punisher.sql
deleted file mode 100644
index b8beb42..0000000
--- a/drizzle/0007_outstanding_punisher.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE TABLE `invite` (
- `id` text PRIMARY KEY NOT NULL,
- `server_id` text NOT NULL,
- `code` text NOT NULL,
- FOREIGN KEY (`server_id`) REFERENCES `server`(`id`) ON UPDATE no action ON DELETE no action
-);
---> statement-breakpoint
-ALTER TABLE `friendRequest` ADD `from_username` text NOT NULL REFERENCES user(id);--> statement-breakpoint
-ALTER TABLE `friendRequest` ADD `to_username` text NOT NULL REFERENCES user(id);
\ No newline at end of file
diff --git a/drizzle/0008_mute_lilandra.sql b/drizzle/0008_mute_lilandra.sql
deleted file mode 100644
index 5ab8d4a..0000000
--- a/drizzle/0008_mute_lilandra.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE TABLE `directMessage` (
- `id` text PRIMARY KEY NOT NULL,
- `name` text NOT NULL,
- `server_id` text NOT NULL,
- `messages` text DEFAULT '[]' NOT NULL,
- FOREIGN KEY (`server_id`) REFERENCES `server`(`id`) ON UPDATE no action ON DELETE no action
-);
---> statement-breakpoint
-ALTER TABLE `user` ADD `status_overwrite` integer DEFAULT 3 NOT NULL;
\ No newline at end of file
diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json
index 985778a..3e26c3d 100644
--- a/drizzle/meta/0000_snapshot.json
+++ b/drizzle/meta/0000_snapshot.json
@@ -1,9 +1,393 @@
{
"version": "6",
"dialect": "sqlite",
- "id": "053c418c-34da-4776-88a4-2e048c6a4637",
+ "id": "bce65872-fa2f-4adc-b86f-af9880038bc8",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
+ "channel": {
+ "name": "channel",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "messages": {
+ "name": "messages",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "channel_server_id_server_id_fk": {
+ "name": "channel_server_id_server_id_fk",
+ "tableFrom": "channel",
+ "tableTo": "server",
+ "columnsFrom": [
+ "server_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "directMessage": {
+ "name": "directMessage",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "first_member": {
+ "name": "first_member",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "second_member": {
+ "name": "second_member",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "messages": {
+ "name": "messages",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "directMessage_first_member_user_id_fk": {
+ "name": "directMessage_first_member_user_id_fk",
+ "tableFrom": "directMessage",
+ "tableTo": "user",
+ "columnsFrom": [
+ "first_member"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "directMessage_second_member_user_id_fk": {
+ "name": "directMessage_second_member_user_id_fk",
+ "tableFrom": "directMessage",
+ "tableTo": "user",
+ "columnsFrom": [
+ "second_member"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "friendRequest": {
+ "name": "friendRequest",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "from_user": {
+ "name": "from_user",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "from_username": {
+ "name": "from_username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "to_username": {
+ "name": "to_username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "to_user": {
+ "name": "to_user",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "friendRequest_from_user_user_id_fk": {
+ "name": "friendRequest_from_user_user_id_fk",
+ "tableFrom": "friendRequest",
+ "tableTo": "user",
+ "columnsFrom": [
+ "from_user"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "friendRequest_from_username_user_id_fk": {
+ "name": "friendRequest_from_username_user_id_fk",
+ "tableFrom": "friendRequest",
+ "tableTo": "user",
+ "columnsFrom": [
+ "from_username"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "friendRequest_to_username_user_id_fk": {
+ "name": "friendRequest_to_username_user_id_fk",
+ "tableFrom": "friendRequest",
+ "tableTo": "user",
+ "columnsFrom": [
+ "to_username"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "friendRequest_to_user_user_id_fk": {
+ "name": "friendRequest_to_user_user_id_fk",
+ "tableFrom": "friendRequest",
+ "tableTo": "user",
+ "columnsFrom": [
+ "to_user"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "group": {
+ "name": "group",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "owner": {
+ "name": "owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "members": {
+ "name": "members",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "messages": {
+ "name": "messages",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "group_owner_user_id_fk": {
+ "name": "group_owner_user_id_fk",
+ "tableFrom": "group",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "invite": {
+ "name": "invite",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "invite_server_id_server_id_fk": {
+ "name": "invite_server_id_server_id_fk",
+ "tableFrom": "invite",
+ "tableTo": "server",
+ "columnsFrom": [
+ "server_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "server": {
+ "name": "server",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "owner": {
+ "name": "owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "members": {
+ "name": "members",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "channels": {
+ "name": "channels",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "server_owner_user_id_fk": {
+ "name": "server_owner_user_id_fk",
+ "tableFrom": "server",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
"session": {
"name": "session",
"columns": {
@@ -59,13 +443,6 @@
"notNull": true,
"autoincrement": false
},
- "age": {
- "name": "age",
- "type": "integer",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
"username": {
"name": "username",
"type": "text",
@@ -73,12 +450,51 @@
"notNull": true,
"autoincrement": false
},
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
"password_hash": {
"name": "password_hash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
+ },
+ "status_overwrite": {
+ "name": "status_overwrite",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 3
+ },
+ "friends": {
+ "name": "friends",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "servers": {
+ "name": "servers",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "groups": {
+ "name": "groups",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
}
},
"indexes": {
@@ -88,6 +504,13 @@
"username"
],
"isUnique": true
+ },
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
}
},
"foreignKeys": {},
diff --git a/drizzle/meta/0001_snapshot.json b/drizzle/meta/0001_snapshot.json
deleted file mode 100644
index efbb0c0..0000000
--- a/drizzle/meta/0001_snapshot.json
+++ /dev/null
@@ -1,123 +0,0 @@
-{
- "version": "6",
- "dialect": "sqlite",
- "id": "8eb771ed-36ad-43c2-a76a-3c704801326a",
- "prevId": "053c418c-34da-4776-88a4-2e048c6a4637",
- "tables": {
- "session": {
- "name": "session",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_user_id_user_id_fk": {
- "name": "session_user_id_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "user": {
- "name": "user",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "age": {
- "name": "age",
- "type": "integer",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "password_hash": {
- "name": "password_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {
- "user_username_unique": {
- "name": "user_username_unique",
- "columns": [
- "username"
- ],
- "isUnique": true
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "columns": [
- "email"
- ],
- "isUnique": true
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- }
- },
- "views": {},
- "enums": {},
- "_meta": {
- "schemas": {},
- "tables": {},
- "columns": {}
- },
- "internal": {
- "indexes": {}
- }
-}
\ No newline at end of file
diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json
deleted file mode 100644
index d6e1dc3..0000000
--- a/drizzle/meta/0002_snapshot.json
+++ /dev/null
@@ -1,131 +0,0 @@
-{
- "version": "6",
- "dialect": "sqlite",
- "id": "6f6aa2cb-1b39-4cff-a1c6-915735fab505",
- "prevId": "8eb771ed-36ad-43c2-a76a-3c704801326a",
- "tables": {
- "session": {
- "name": "session",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_user_id_user_id_fk": {
- "name": "session_user_id_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "user": {
- "name": "user",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "age": {
- "name": "age",
- "type": "integer",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "password_hash": {
- "name": "password_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "friends": {
- "name": "friends",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {
- "user_username_unique": {
- "name": "user_username_unique",
- "columns": [
- "username"
- ],
- "isUnique": true
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "columns": [
- "email"
- ],
- "isUnique": true
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- }
- },
- "views": {},
- "enums": {},
- "_meta": {
- "schemas": {},
- "tables": {},
- "columns": {}
- },
- "internal": {
- "indexes": {}
- }
-}
\ No newline at end of file
diff --git a/drizzle/meta/0003_snapshot.json b/drizzle/meta/0003_snapshot.json
deleted file mode 100644
index fb9c4c4..0000000
--- a/drizzle/meta/0003_snapshot.json
+++ /dev/null
@@ -1,238 +0,0 @@
-{
- "version": "6",
- "dialect": "sqlite",
- "id": "218a80a3-4754-48c7-8173-099613497b99",
- "prevId": "6f6aa2cb-1b39-4cff-a1c6-915735fab505",
- "tables": {
- "group": {
- "name": "group",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "group_owner_user_id_fk": {
- "name": "group_owner_user_id_fk",
- "tableFrom": "group",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "server": {
- "name": "server",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "channels": {
- "name": "channels",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "server_owner_user_id_fk": {
- "name": "server_owner_user_id_fk",
- "tableFrom": "server",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "session": {
- "name": "session",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_user_id_user_id_fk": {
- "name": "session_user_id_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "user": {
- "name": "user",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "password_hash": {
- "name": "password_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "friends": {
- "name": "friends",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {
- "user_username_unique": {
- "name": "user_username_unique",
- "columns": [
- "username"
- ],
- "isUnique": true
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "columns": [
- "email"
- ],
- "isUnique": true
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- }
- },
- "views": {},
- "enums": {},
- "_meta": {
- "schemas": {},
- "tables": {},
- "columns": {}
- },
- "internal": {
- "indexes": {}
- }
-}
\ No newline at end of file
diff --git a/drizzle/meta/0004_snapshot.json b/drizzle/meta/0004_snapshot.json
deleted file mode 100644
index 3ffc7cb..0000000
--- a/drizzle/meta/0004_snapshot.json
+++ /dev/null
@@ -1,254 +0,0 @@
-{
- "version": "6",
- "dialect": "sqlite",
- "id": "8592fa88-aea8-41f9-a183-8608ec4c4323",
- "prevId": "218a80a3-4754-48c7-8173-099613497b99",
- "tables": {
- "group": {
- "name": "group",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "group_owner_user_id_fk": {
- "name": "group_owner_user_id_fk",
- "tableFrom": "group",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "server": {
- "name": "server",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "channels": {
- "name": "channels",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "server_owner_user_id_fk": {
- "name": "server_owner_user_id_fk",
- "tableFrom": "server",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "session": {
- "name": "session",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_user_id_user_id_fk": {
- "name": "session_user_id_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "user": {
- "name": "user",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "password_hash": {
- "name": "password_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "friends": {
- "name": "friends",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "servers": {
- "name": "servers",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "groups": {
- "name": "groups",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {
- "user_username_unique": {
- "name": "user_username_unique",
- "columns": [
- "username"
- ],
- "isUnique": true
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "columns": [
- "email"
- ],
- "isUnique": true
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- }
- },
- "views": {},
- "enums": {},
- "_meta": {
- "schemas": {},
- "tables": {},
- "columns": {}
- },
- "internal": {
- "indexes": {}
- }
-}
\ No newline at end of file
diff --git a/drizzle/meta/0005_snapshot.json b/drizzle/meta/0005_snapshot.json
deleted file mode 100644
index 0e2f7dd..0000000
--- a/drizzle/meta/0005_snapshot.json
+++ /dev/null
@@ -1,307 +0,0 @@
-{
- "version": "6",
- "dialect": "sqlite",
- "id": "69be2f8f-70ca-4016-b10f-60f64a99af73",
- "prevId": "8592fa88-aea8-41f9-a183-8608ec4c4323",
- "tables": {
- "channel": {
- "name": "channel",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "server_id": {
- "name": "server_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "messages": {
- "name": "messages",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "channel_server_id_server_id_fk": {
- "name": "channel_server_id_server_id_fk",
- "tableFrom": "channel",
- "tableTo": "server",
- "columnsFrom": [
- "server_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "group": {
- "name": "group",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "group_owner_user_id_fk": {
- "name": "group_owner_user_id_fk",
- "tableFrom": "group",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "server": {
- "name": "server",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "channels": {
- "name": "channels",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "server_owner_user_id_fk": {
- "name": "server_owner_user_id_fk",
- "tableFrom": "server",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "session": {
- "name": "session",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_user_id_user_id_fk": {
- "name": "session_user_id_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "user": {
- "name": "user",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "password_hash": {
- "name": "password_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "friends": {
- "name": "friends",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "servers": {
- "name": "servers",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "groups": {
- "name": "groups",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {
- "user_username_unique": {
- "name": "user_username_unique",
- "columns": [
- "username"
- ],
- "isUnique": true
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "columns": [
- "email"
- ],
- "isUnique": true
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- }
- },
- "views": {},
- "enums": {},
- "_meta": {
- "schemas": {},
- "tables": {},
- "columns": {}
- },
- "internal": {
- "indexes": {}
- }
-}
\ No newline at end of file
diff --git a/drizzle/meta/0006_snapshot.json b/drizzle/meta/0006_snapshot.json
deleted file mode 100644
index 7ac207d..0000000
--- a/drizzle/meta/0006_snapshot.json
+++ /dev/null
@@ -1,365 +0,0 @@
-{
- "version": "6",
- "dialect": "sqlite",
- "id": "e809c266-891b-4355-a87c-facd55a5293a",
- "prevId": "69be2f8f-70ca-4016-b10f-60f64a99af73",
- "tables": {
- "channel": {
- "name": "channel",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "server_id": {
- "name": "server_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "messages": {
- "name": "messages",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "channel_server_id_server_id_fk": {
- "name": "channel_server_id_server_id_fk",
- "tableFrom": "channel",
- "tableTo": "server",
- "columnsFrom": [
- "server_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "friendRequest": {
- "name": "friendRequest",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "from_user": {
- "name": "from_user",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "to_user": {
- "name": "to_user",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "friendRequest_from_user_user_id_fk": {
- "name": "friendRequest_from_user_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "from_user"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "friendRequest_to_user_user_id_fk": {
- "name": "friendRequest_to_user_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "to_user"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "group": {
- "name": "group",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "group_owner_user_id_fk": {
- "name": "group_owner_user_id_fk",
- "tableFrom": "group",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "server": {
- "name": "server",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "channels": {
- "name": "channels",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "server_owner_user_id_fk": {
- "name": "server_owner_user_id_fk",
- "tableFrom": "server",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "session": {
- "name": "session",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_user_id_user_id_fk": {
- "name": "session_user_id_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "user": {
- "name": "user",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "password_hash": {
- "name": "password_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "friends": {
- "name": "friends",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "servers": {
- "name": "servers",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "groups": {
- "name": "groups",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {
- "user_username_unique": {
- "name": "user_username_unique",
- "columns": [
- "username"
- ],
- "isUnique": true
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "columns": [
- "email"
- ],
- "isUnique": true
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- }
- },
- "views": {},
- "enums": {},
- "_meta": {
- "schemas": {},
- "tables": {},
- "columns": {}
- },
- "internal": {
- "indexes": {}
- }
-}
\ No newline at end of file
diff --git a/drizzle/meta/0007_snapshot.json b/drizzle/meta/0007_snapshot.json
deleted file mode 100644
index 29029e3..0000000
--- a/drizzle/meta/0007_snapshot.json
+++ /dev/null
@@ -1,450 +0,0 @@
-{
- "version": "6",
- "dialect": "sqlite",
- "id": "c0ac7678-4e2c-433f-ac26-73c7b88cc38b",
- "prevId": "e809c266-891b-4355-a87c-facd55a5293a",
- "tables": {
- "channel": {
- "name": "channel",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "server_id": {
- "name": "server_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "messages": {
- "name": "messages",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "channel_server_id_server_id_fk": {
- "name": "channel_server_id_server_id_fk",
- "tableFrom": "channel",
- "tableTo": "server",
- "columnsFrom": [
- "server_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "friendRequest": {
- "name": "friendRequest",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "from_user": {
- "name": "from_user",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "from_username": {
- "name": "from_username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "to_username": {
- "name": "to_username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "to_user": {
- "name": "to_user",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "friendRequest_from_user_user_id_fk": {
- "name": "friendRequest_from_user_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "from_user"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "friendRequest_from_username_user_id_fk": {
- "name": "friendRequest_from_username_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "from_username"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "friendRequest_to_username_user_id_fk": {
- "name": "friendRequest_to_username_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "to_username"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "friendRequest_to_user_user_id_fk": {
- "name": "friendRequest_to_user_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "to_user"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "group": {
- "name": "group",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "group_owner_user_id_fk": {
- "name": "group_owner_user_id_fk",
- "tableFrom": "group",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "invite": {
- "name": "invite",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "server_id": {
- "name": "server_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "invite_server_id_server_id_fk": {
- "name": "invite_server_id_server_id_fk",
- "tableFrom": "invite",
- "tableTo": "server",
- "columnsFrom": [
- "server_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "server": {
- "name": "server",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "channels": {
- "name": "channels",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "server_owner_user_id_fk": {
- "name": "server_owner_user_id_fk",
- "tableFrom": "server",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "session": {
- "name": "session",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_user_id_user_id_fk": {
- "name": "session_user_id_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "user": {
- "name": "user",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "password_hash": {
- "name": "password_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "friends": {
- "name": "friends",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "servers": {
- "name": "servers",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "groups": {
- "name": "groups",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {
- "user_username_unique": {
- "name": "user_username_unique",
- "columns": [
- "username"
- ],
- "isUnique": true
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "columns": [
- "email"
- ],
- "isUnique": true
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- }
- },
- "views": {},
- "enums": {},
- "_meta": {
- "schemas": {},
- "tables": {},
- "columns": {}
- },
- "internal": {
- "indexes": {}
- }
-}
\ No newline at end of file
diff --git a/drizzle/meta/0008_snapshot.json b/drizzle/meta/0008_snapshot.json
deleted file mode 100644
index 3f8dbe8..0000000
--- a/drizzle/meta/0008_snapshot.json
+++ /dev/null
@@ -1,511 +0,0 @@
-{
- "version": "6",
- "dialect": "sqlite",
- "id": "bd16f3db-5965-4d36-89b7-d259cbd21149",
- "prevId": "c0ac7678-4e2c-433f-ac26-73c7b88cc38b",
- "tables": {
- "channel": {
- "name": "channel",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "server_id": {
- "name": "server_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "messages": {
- "name": "messages",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "channel_server_id_server_id_fk": {
- "name": "channel_server_id_server_id_fk",
- "tableFrom": "channel",
- "tableTo": "server",
- "columnsFrom": [
- "server_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "directMessage": {
- "name": "directMessage",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "server_id": {
- "name": "server_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "messages": {
- "name": "messages",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "directMessage_server_id_server_id_fk": {
- "name": "directMessage_server_id_server_id_fk",
- "tableFrom": "directMessage",
- "tableTo": "server",
- "columnsFrom": [
- "server_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "friendRequest": {
- "name": "friendRequest",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "from_user": {
- "name": "from_user",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "from_username": {
- "name": "from_username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "to_username": {
- "name": "to_username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "to_user": {
- "name": "to_user",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "friendRequest_from_user_user_id_fk": {
- "name": "friendRequest_from_user_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "from_user"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "friendRequest_from_username_user_id_fk": {
- "name": "friendRequest_from_username_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "from_username"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "friendRequest_to_username_user_id_fk": {
- "name": "friendRequest_to_username_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "to_username"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "friendRequest_to_user_user_id_fk": {
- "name": "friendRequest_to_user_user_id_fk",
- "tableFrom": "friendRequest",
- "tableTo": "user",
- "columnsFrom": [
- "to_user"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "group": {
- "name": "group",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "group_owner_user_id_fk": {
- "name": "group_owner_user_id_fk",
- "tableFrom": "group",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "invite": {
- "name": "invite",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "server_id": {
- "name": "server_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "invite_server_id_server_id_fk": {
- "name": "invite_server_id_server_id_fk",
- "tableFrom": "invite",
- "tableTo": "server",
- "columnsFrom": [
- "server_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "server": {
- "name": "server",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "owner": {
- "name": "owner",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "members": {
- "name": "members",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "channels": {
- "name": "channels",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "server_owner_user_id_fk": {
- "name": "server_owner_user_id_fk",
- "tableFrom": "server",
- "tableTo": "user",
- "columnsFrom": [
- "owner"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "session": {
- "name": "session",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_user_id_user_id_fk": {
- "name": "session_user_id_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- },
- "user": {
- "name": "user",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "password_hash": {
- "name": "password_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "status_overwrite": {
- "name": "status_overwrite",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": 3
- },
- "friends": {
- "name": "friends",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "servers": {
- "name": "servers",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- },
- "groups": {
- "name": "groups",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'[]'"
- }
- },
- "indexes": {
- "user_username_unique": {
- "name": "user_username_unique",
- "columns": [
- "username"
- ],
- "isUnique": true
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "columns": [
- "email"
- ],
- "isUnique": true
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {}
- }
- },
- "views": {},
- "enums": {},
- "_meta": {
- "schemas": {},
- "tables": {},
- "columns": {}
- },
- "internal": {
- "indexes": {}
- }
-}
\ No newline at end of file
diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json
index 7217414..c838996 100644
--- a/drizzle/meta/_journal.json
+++ b/drizzle/meta/_journal.json
@@ -5,64 +5,8 @@
{
"idx": 0,
"version": "6",
- "when": 1767358712855,
- "tag": "0000_hard_thaddeus_ross",
- "breakpoints": true
- },
- {
- "idx": 1,
- "version": "6",
- "when": 1767361487418,
- "tag": "0001_melted_goliath",
- "breakpoints": true
- },
- {
- "idx": 2,
- "version": "6",
- "when": 1767530520182,
- "tag": "0002_fair_sasquatch",
- "breakpoints": true
- },
- {
- "idx": 3,
- "version": "6",
- "when": 1767530666249,
- "tag": "0003_wise_lucky_pierre",
- "breakpoints": true
- },
- {
- "idx": 4,
- "version": "6",
- "when": 1767530823274,
- "tag": "0004_fair_stature",
- "breakpoints": true
- },
- {
- "idx": 5,
- "version": "6",
- "when": 1767531680914,
- "tag": "0005_mute_mephisto",
- "breakpoints": true
- },
- {
- "idx": 6,
- "version": "6",
- "when": 1767537153441,
- "tag": "0006_gifted_machine_man",
- "breakpoints": true
- },
- {
- "idx": 7,
- "version": "6",
- "when": 1767543898231,
- "tag": "0007_outstanding_punisher",
- "breakpoints": true
- },
- {
- "idx": 8,
- "version": "6",
- "when": 1767549353944,
- "tag": "0008_mute_lilandra",
+ "when": 1767559403688,
+ "tag": "0000_amusing_shatterstar",
"breakpoints": true
}
]
diff --git a/src/hooks.server.ts b/src/hooks.server.ts
index 3aff2d3..1df6227 100644
--- a/src/hooks.server.ts
+++ b/src/hooks.server.ts
@@ -1,8 +1,5 @@
import type { Handle } from '@sveltejs/kit';
import * as auth from '$lib/server/auth';
-import { kvStore } from '$lib/server/db';
-import { _isUserConnected, _sendToSubscribers } from './routes/api/updates/+server';
-import { Status } from '$lib';
const handleAuth: Handle = async ({ event, resolve }) => {
const sessionToken = event.cookies.get(auth.sessionCookieName);
diff --git a/src/lib/components/app-sidebar.svelte b/src/lib/components/app-sidebar.svelte
index 9e3f76e..7e6d602 100644
--- a/src/lib/components/app-sidebar.svelte
+++ b/src/lib/components/app-sidebar.svelte
@@ -1,312 +1,311 @@
-
-
-
-
-
-
- chat.sad.ovh
-
-
-
-
-
-
-
+
+
+
+
+
+
+ chat.sad.ovh
+
+
+
-
-
-
-
-
-
-
-
-
-
- Friends
-
-
-
-
-
-
- {#each data.friends as friend (friend.id)}
-
-
- {
- e.preventDefault();
- currentPage = friend.id;
- }}
- user={friend}
- >
-
-
- {/each}
-
-
-
-
+
+ Cancel
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Friends
+
+
+
+
+
+
+ {#each data.friends as friend (friend.id)}
+
+
+ {
+ e.preventDefault();
+ currentPage = friend.id;
+ }}
+ user={friend}
+ >
+
+
+ {/each}
+
+
+
+
-
-
-
-
- Groups
-
-
-
-
-
-
- {#each data.groups as group (group.id)}
-
-
- {
- e.preventDefault();
- currentPage = group.id;
- }}
- href="##"
- >
- {group.name} ({group.members} members)
-
-
-
- {/each}
-
-
-
-
+
+
+
+
+ Groups
+
+
+
+
+
+
+ {#each data.groups as group (group.id)}
+
+
+ {
+ e.preventDefault();
+ currentPage = group.id;
+ }}
+ href="##"
+ >
+ {group.name} ({group.members} members)
+
+
+
+ {/each}
+
+
+
+
-
-
-
-
- Servers
-
-
-
-
-
-
- {#each data.servers as server (server.id)}
-
-
- {
- e.preventDefault();
- currentPage = server.id;
- }}
- href="##"
- class="flex items-center gap-2"
- >
-
- {server.name}
-
-
-
- {/each}
-
-
-
-
-
-
-
-
+
+
+
+
+ Servers
+
+
+
+
+
+
+ {#each data.servers as server (server.id)}
+
+
+ {
+ e.preventDefault();
+ currentPage = server.id;
+ }}
+ href="##"
+ class="flex items-center gap-2"
+ >
+
+ {server.name}
+
+
+
+ {/each}
+
+
+
+
+
+
+
+
diff --git a/src/lib/components/hooks/is-mobile.svelte.ts b/src/lib/components/hooks/is-mobile.svelte.ts
deleted file mode 100644
index 4829c00..0000000
--- a/src/lib/components/hooks/is-mobile.svelte.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { MediaQuery } from "svelte/reactivity";
-
-const DEFAULT_MOBILE_BREAKPOINT = 768;
-
-export class IsMobile extends MediaQuery {
- constructor(breakpoint: number = DEFAULT_MOBILE_BREAKPOINT) {
- super(`max-width: ${breakpoint - 1}px`);
- }
-}
diff --git a/src/lib/index.ts b/src/lib/index.ts
index bbaac9c..c23c2f2 100644
--- a/src/lib/index.ts
+++ b/src/lib/index.ts
@@ -4,11 +4,12 @@ export const UserID = definePrefix('user');
export const GroupID = definePrefix('group');
export const ServerID = definePrefix('srv');
export const FriendRequestID = definePrefix('frq');
+export const DirectMessageID = definePrefix('dmid');
export type UserId = Puuid<'user'>;
export type GroupId = Puuid<'group'>;
export type ServerId = Puuid<'srv'>;
-export type FriendRequestID = Puuid<'frq'>;
+export type DirectMessageId = Puuid<'dmid'>;
export const Status: Record = {
OFFLINE: 1,
@@ -20,6 +21,7 @@ export type OverviewUser = {
id: string;
username: string;
image: string;
+ dmId?: string;
};
export type OverviewServer = {
diff --git a/src/lib/server/auth.ts b/src/lib/server/auth.ts
index d599477..0ef8352 100644
--- a/src/lib/server/auth.ts
+++ b/src/lib/server/auth.ts
@@ -4,6 +4,7 @@ import { sha256 } from '@oslojs/crypto/sha2';
import { encodeBase64url, encodeHexLowerCase } from '@oslojs/encoding';
import { db } from '$lib/server/db';
import * as table from '$lib/server/db/schema';
+import { _findDmId } from '../../routes/api/messages/[[grp_srv_dm]]/[[channelId]]/[[channelId]]/+server';
const DAY_IN_MS = 1000 * 60 * 60 * 24;
@@ -63,15 +64,25 @@ export async function validateSessionToken(token: string) {
.set({ expiresAt: session.expiresAt })
.where(eq(table.session.id, session.id));
}
- const friends = (user.friends as string[]).length
- ? await db
- .select({
- id: table.user.id,
- username: table.user.username
- })
- .from(table.user)
- .where(inArray(table.user.id, user.friends as string[]))
- : [];
+ const friends = await Promise.all(
+ ((user.friends as string[]).length
+ ? await db
+ .select({
+ id: table.user.id,
+ username: table.user.username
+ })
+ .from(table.user)
+ .where(inArray(table.user.id, user.friends as string[]))
+ : []
+ ).map(async (z) => {
+ const dmid = await _findDmId(z.id, user.id);
+
+ return {
+ ...z,
+ dmId: dmid
+ };
+ })
+ );
const servers = (user.servers as string[]).length
? await db
@@ -99,6 +110,8 @@ export async function validateSessionToken(token: string) {
.select({
id: table.friendRequest.id,
fromUser: table.friendRequest.fromUser,
+ fromUsername: table.friendRequest.fromUsername,
+ toUsername: table.friendRequest.toUsername,
toUser: table.friendRequest.toUser
})
.from(table.friendRequest)
diff --git a/src/lib/server/db/schema.ts b/src/lib/server/db/schema.ts
index b42bdd0..1b65b92 100644
--- a/src/lib/server/db/schema.ts
+++ b/src/lib/server/db/schema.ts
@@ -37,7 +37,8 @@ export const group = sqliteTable('group', {
owner: text('owner')
.notNull()
.references(() => user.id),
- members: text('members', { mode: 'json' }).default([]).notNull()
+ members: text('members', { mode: 'json' }).default([]).notNull(),
+ messages: text('messages', { mode: 'json' }).default([]).notNull()
});
export const channel = sqliteTable('channel', {
@@ -51,10 +52,12 @@ export const channel = sqliteTable('channel', {
export const directMessage = sqliteTable('directMessage', {
id: text('id').primaryKey(),
- name: text('name').notNull(),
- serverId: text('server_id')
+ firstMember: text('first_member')
.notNull()
- .references(() => server.id),
+ .references(() => user.id),
+ secondMember: text('second_member')
+ .notNull()
+ .references(() => user.id),
messages: text('messages', { mode: 'json' }).default([]).notNull()
});
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 634542d..cff89f1 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -4,6 +4,7 @@ import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
+
export function formatTimestamp(dateString: string) {
const date = new Date(dateString);
const now = new Date();
diff --git a/src/routes/api/messages/[[grp_srv_dm]]/[[channelId]]/[[channelId]]/+server.ts b/src/routes/api/messages/[[grp_srv_dm]]/[[channelId]]/[[channelId]]/+server.ts
index c379631..665c0fa 100644
--- a/src/routes/api/messages/[[grp_srv_dm]]/[[channelId]]/[[channelId]]/+server.ts
+++ b/src/routes/api/messages/[[grp_srv_dm]]/[[channelId]]/[[channelId]]/+server.ts
@@ -1,7 +1,59 @@
-import { fail, json } from '@sveltejs/kit';
+import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
-import { GroupID, ServerID, UserID } from '$lib';
+import { db } from '$lib/server/db';
+import * as table from '$lib/server/db/schema';
+import { DirectMessageID, GroupID, ServerID } from '$lib';
+import { eq, or } from 'drizzle-orm';
+import { _sendToSubscribers } from '../../../../updates/+server';
+import { and } from 'drizzle-orm';
+interface Message {
+ id: string;
+ authorId: string;
+ content: string;
+ timestamp: number;
+}
+
+export async function _findDm(member_one: string, member_two: string) {
+ return await db
+ .select()
+ .from(table.directMessage)
+ .where(
+ or(
+ and(
+ eq(table.directMessage.secondMember, member_two),
+ eq(table.directMessage.firstMember, member_one)
+ ),
+ and(
+ eq(table.directMessage.firstMember, member_two),
+ eq(table.directMessage.secondMember, member_one)
+ )
+ )
+ );
+}
+export async function _findDmId(
+ member_one: string,
+ member_two: string
+): Promise {
+ return (
+ await db
+ .select({ id: table.directMessage.id })
+ .from(table.directMessage)
+ .where(
+ or(
+ and(
+ eq(table.directMessage.secondMember, member_two),
+ eq(table.directMessage.firstMember, member_one)
+ ),
+ and(
+ eq(table.directMessage.firstMember, member_two),
+ eq(table.directMessage.secondMember, member_one)
+ )
+ )
+ )
+ .limit(1)
+ )?.[0]?.id;
+}
export const GET: RequestHandler = async ({ params, locals }) => {
if (!locals.user) {
return new Response('No authentication', { status: 401 });
@@ -11,38 +63,32 @@ export const GET: RequestHandler = async ({ params, locals }) => {
if (!grp_srv_dm) {
return new Response('Missing group, server, or DM ID.', { status: 400 });
}
- let messages = [];
+
+ let messages: Message[] = [];
let type = '';
if (GroupID.is(grp_srv_dm)) {
type = 'group';
- messages = Array.from({ length: 5 }, (_, i) => ({
- id: crypto.randomUUID(),
- authorId: `user_${Math.floor(Math.random() * 10)}`,
- content: 'group message ' + (i + 1),
- timestamp: Date.now() - Math.floor(Math.random() * 100000)
- }));
+ const g = (await db.select().from(table.group).where(eq(table.group.id, grp_srv_dm)))[0];
+ if (!g) return new Response('Group not found.', { status: 404 });
+
+ messages = g.messages ?? [];
} else if (ServerID.is(grp_srv_dm)) {
type = 'server';
+ if (!channelId) return new Response('Missing channel ID.', { status: 400 });
+ const c = (await db.select().from(table.channel).where(eq(table.channel.id, channelId)))[0];
+ if (!c) return new Response('Channel not found.', { status: 404 });
- if (!channelId) {
- return new Response('Missing channel ID.', { status: 400 });
- }
-
- messages = Array.from({ length: 5 }, (_, i) => ({
- id: crypto.randomUUID(),
- authorId: `user_${Math.floor(Math.random() * 10)}`,
- content: 'server message ' + (i + 1),
- timestamp: Date.now() - Math.floor(Math.random() * 100000)
- }));
- } else if (UserID.is(grp_srv_dm)) {
+ messages = c.messages;
+ } else if (DirectMessageID.is(grp_srv_dm)) {
type = 'dms';
- messages = Array.from({ length: 5 }, (_, i) => ({
- id: crypto.randomUUID(),
- authorId: Math.random() > 0.5 ? locals.user.id : grp_srv_dm,
- content: 'dm message ' + (i + 1),
- timestamp: Date.now() - Math.floor(Math.random() * 100000)
- }));
+ const dm = (
+ await db.select().from(table.directMessage).where(eq(table.directMessage.id, grp_srv_dm))
+ )[0];
+
+ if (!dm) return new Response('DM not found.', { status: 404 });
+
+ messages = dm.messages;
}
return json({
@@ -51,3 +97,67 @@ export const GET: RequestHandler = async ({ params, locals }) => {
messages
});
};
+
+export const POST: RequestHandler = async ({ params, request, locals }) => {
+ if (!locals.user) {
+ return new Response('Unauthorized', { status: 401 });
+ }
+
+ let { grp_srv_dm, channelId } = params;
+ if (!grp_srv_dm) return new Response('Missing Group/Server/DM id.', { status: 400 });
+ const data = await request.json();
+ const { content } = data;
+
+ if (!content) return new Response('Missing message content.', { status: 400 });
+
+ let messages: Message[] = [];
+ let type = '';
+
+ const message = {
+ id: crypto.randomUUID(),
+ authorId: locals.user.id,
+ content,
+ timestamp: Date.now()
+ };
+
+ if (GroupID.is(grp_srv_dm)) {
+ type = 'group';
+ const g = (await db.select().from(table.group).where(eq(table.group.id, grp_srv_dm)))[0];
+ if (!g) return new Response('Group not found.', { status: 404 });
+ messages = g.messages ?? [];
+
+ messages.push(message);
+
+ await db.update(table.group).set({ messages }).where(eq(table.group.id, grp_srv_dm));
+ } else if (ServerID.is(grp_srv_dm)) {
+ type = 'server';
+ if (!channelId) return new Response('Missing channel ID.', { status: 400 });
+ const c = (await db.select().from(table.channel).where(eq(table.channel.id, channelId)))[0];
+ if (!c) return new Response('Channel not found.', { status: 404 });
+ messages = c.messages ?? [];
+
+ messages.push(message);
+
+ await db.update(table.channel).set({ messages }).where(eq(table.channel.id, channelId));
+ } else if (DirectMessageID.is(grp_srv_dm)) {
+ type = 'dms';
+ const dm = (
+ await db.select().from(table.directMessage).where(eq(table.directMessage.id, grp_srv_dm))
+ )[0];
+
+ if (!dm) return new Response('DM not found.', { status: 404 });
+
+ messages = dm.messages ?? [];
+
+ messages.push(message);
+
+ await db.update(table.directMessage).set({ messages }).where(eq(table.directMessage.id, dm.id));
+
+ _sendToSubscribers(dm.id, { type: 'message', id: dm.id, message });
+ return json({ type, id: dm.id, messages });
+ }
+
+ _sendToSubscribers(grp_srv_dm, { type: 'message', id: grp_srv_dm, message });
+
+ return json({ type, id: grp_srv_dm, messages });
+};
diff --git a/src/routes/api/updates/+server.ts b/src/routes/api/updates/+server.ts
index 33b9388..c3608e7 100644
--- a/src/routes/api/updates/+server.ts
+++ b/src/routes/api/updates/+server.ts
@@ -1,17 +1,18 @@
import { Status } from '$lib';
import { kvStore } from '$lib/server/db/index.js';
+import { json } from '@sveltejs/kit';
interface SubscribedTo {
- subscribed: string[];
+ subscribed: string[]; // any ID (including channels, dms, et cetera can be added in here, to send SSE data to any group of users)
userId: string;
controller: ReadableStreamDefaultController;
}
export const _clients = new Map();
-export function _sendToSubscribers(userId: string, payload: unknown) {
+export function _sendToSubscribers(id: string, payload: unknown) {
for (const [key, client] of _clients) {
- if (client.subscribed.includes(userId)) {
+ if (client.subscribed.includes(id)) {
try {
client.controller.enqueue(`data: ${JSON.stringify(payload)}\n\n`);
} catch {
@@ -30,7 +31,7 @@ export function _isUserConnected(userId: string): boolean {
export async function GET({ locals, request }) {
if (!locals.user) {
- return new Response('No authentication', { status: 401 });
+ return json({ error: 'Unauthorized' }, { status: 401 });
}
const userId = locals.user.id;
@@ -38,14 +39,14 @@ export async function GET({ locals, request }) {
const subscribed = locals.user.friends.map((f) => f.id);
const overwrite = locals.user.statusOverwrite;
- const reqId = crypto.randomUUID();
+ const sessionId = crypto.randomUUID();
const stream = new ReadableStream({
start(controller) {
- _clients.set(reqId, { subscribed, userId, controller });
+ _clients.set(sessionId, { subscribed, userId, controller });
console.log(`SSE Client opened. total: ${_clients.size}`);
- controller.enqueue(`data: ${JSON.stringify({ type: 'connected' })}\n\n`);
+ controller.enqueue(`data: ${JSON.stringify({ type: 'connected', sessionId })}\n\n`);
if (overwrite === Status.DND) {
kvStore.set(`user-${userId}-state`, Status.DND);
@@ -56,7 +57,7 @@ export async function GET({ locals, request }) {
}
request.signal.addEventListener('abort', () => {
- _clients.delete(reqId);
+ _clients.delete(sessionId);
console.log(`SSE Client aborted. total: ${_clients.size}`);
if (_isUserConnected(userId)) return;
diff --git a/src/routes/api/updates/[sessionId]/+server.ts b/src/routes/api/updates/[sessionId]/+server.ts
new file mode 100644
index 0000000..2393d9f
--- /dev/null
+++ b/src/routes/api/updates/[sessionId]/+server.ts
@@ -0,0 +1,111 @@
+import { json } from '@sveltejs/kit';
+import type { RequestHandler } from './$types';
+import { _clients } from '../+server';
+import { DirectMessageID } from '$lib';
+import { db } from '$lib/server/db';
+import * as table from '$lib/server/db/schema';
+import { or } from 'drizzle-orm';
+import { eq } from 'drizzle-orm';
+
+export const POST: RequestHandler = async ({ params, request, locals }) => {
+ if (!locals.user) {
+ return json({ error: 'Unauthorized' }, { status: 401 });
+ }
+
+ const { sessionId } = params;
+ if (!sessionId) {
+ return json({ error: 'Missing sessionId' }, { status: 400 });
+ }
+
+ const client = _clients.get(sessionId);
+ if (!client) {
+ return json({ error: 'Client not found' }, { status: 404 });
+ }
+
+ if (client.userId !== locals.user.id) {
+ return json({ error: 'Unauthorized sessionID access' }, { status: 401 });
+ }
+
+ const body = await request.json();
+ const { subscribeTo } = body;
+
+ if (typeof subscribeTo !== 'string' || !subscribeTo.trim()) {
+ return json({ error: 'Invalid subscribeTo value' }, { status: 400 });
+ }
+
+ let isValidDmid = false;
+
+ if (DirectMessageID.is(subscribeTo)) {
+ const find = await db
+ .select()
+ .from(table.directMessage)
+ .where(
+ or(
+ eq(table.directMessage.firstMember, locals.user.id),
+ eq(table.directMessage.secondMember, locals.user.id)
+ )
+ );
+
+ if (find?.length != 0) {
+ isValidDmid = true;
+ }
+ }
+
+ if (
+ !(
+ isValidDmid ||
+ locals.user.groups.find((z) => z.id === subscribeTo) ||
+ locals.user.servers.find((z) => z.id === subscribeTo)
+ )
+ ) {
+ return json({ error: 'Invalid subscription' }, { status: 401 });
+ }
+
+ if (!client.subscribed.includes(subscribeTo)) {
+ client.subscribed.push(subscribeTo);
+ }
+
+ return json({
+ message: `Added ${subscribeTo} to client subscriptions.`,
+ subscribed: client.subscribed
+ });
+};
+
+export const DELETE: RequestHandler = async ({ params, request, locals }) => {
+ if (!locals.user) {
+ return json({ error: 'Unauthorized' }, { status: 401 });
+ }
+
+ const { sessionId } = params;
+ if (!sessionId) {
+ return json({ error: 'Missing sessionId' }, { status: 400 });
+ }
+
+ const client = _clients.get(sessionId);
+ if (!client) {
+ return json({ error: 'Client not found' }, { status: 404 });
+ }
+
+ if (client.userId !== locals.user.id) {
+ return json({ error: 'Unauthorized sessionID access' }, { status: 401 });
+ }
+
+ const body = await request.json();
+ const { subscribeTo } = body;
+
+ if (typeof subscribeTo !== 'string' || !subscribeTo.trim()) {
+ return json({ error: 'Invalid subscribeTo value' }, { status: 400 });
+ }
+
+ const index = client.subscribed.indexOf(subscribeTo);
+ if (index !== -1) {
+ client.subscribed.splice(index, 1);
+ } else {
+ return json({ error: 'Subscription not found' }, { status: 404 });
+ }
+
+ return json({
+ message: `Removed ${subscribeTo} from client subscriptions.`,
+ subscribed: client.subscribed
+ });
+};
diff --git a/src/routes/app/+page.server.ts b/src/routes/app/+page.server.ts
index abdf106..f34758b 100644
--- a/src/routes/app/+page.server.ts
+++ b/src/routes/app/+page.server.ts
@@ -3,7 +3,7 @@ import { getRequestEvent } from '$app/server';
import type { Actions, PageServerLoad } from './$types';
import { db } from '$lib/server/db';
import * as table from '$lib/server/db/schema';
-import { FriendRequestID, ServerID } from '$lib';
+import { DirectMessageID, FriendRequestID, ServerID } from '$lib';
import { eq } from 'drizzle-orm';
import { and } from 'drizzle-orm';
import { type User } from '$lib/server/db/schema';
@@ -72,6 +72,13 @@ export const actions = {
)
.limit(1);
+ await db.insert(table.directMessage).values({
+ id: DirectMessageID.newV4(),
+ firstMember: locals.user!.id,
+ secondMember: user[0].id,
+ messages: []
+ });
+
// add other guy to us
await db.transaction(async (tx) => {
await tx
@@ -99,7 +106,9 @@ export const actions = {
await db.insert(table.friendRequest).values({
id: FriendRequestID.newV4(),
fromUser: locals.user!.id,
- toUser: user[0].id
+ toUser: user[0].id,
+ toUsername: user[0].username,
+ fromUsername: locals.user!.username
});
return { success: true };
diff --git a/src/routes/app/+page.svelte b/src/routes/app/+page.svelte
index d3550b2..549090f 100644
--- a/src/routes/app/+page.svelte
+++ b/src/routes/app/+page.svelte
@@ -20,6 +20,8 @@
import { onMount } from 'svelte';
import type { ActionData } from './$types';
import { formatTimestamp } from '$lib/utils';
+ import Input from '$lib/components/ui/input/input.svelte';
+ import { Button } from '$lib/components/ui/button';
let errorOpen = $state(true);
let { form, data }: { form: ActionData; data: PageServerData } = $props();
@@ -27,6 +29,11 @@
let currentPage: OverviewUser | OverviewGroup | OverviewServer | undefined = $state();
let messages = $state([]);
+ let inputValue = $state();
+
+ let sessionId: string | undefined = $state();
+ let previousSubscription: typeof currentPageID = $state(null);
+
const overview_data: OverviewData = $state({
friends: [],
groups: [],
@@ -52,10 +59,26 @@
if (ServerID.is(currentPageID)) return;
async function getMessages() {
- const req = await fetch('/api/messages/' + currentPageID);
+ const req = await fetch('/api/messages/' + (currentPage!.dmId || currentPageID));
const data = await req.json();
messages = data.messages;
+
+ if (previousSubscription && previousSubscription != (currentPage!.dmId || currentPageID)) {
+ await fetch('/api/updates/' + sessionId, {
+ body: JSON.stringify({ subscribeTo: previousSubscription }),
+ method: 'DELETE'
+ });
+ }
+
+ if (previousSubscription != (currentPage!.dmId || currentPageID)) {
+ await fetch('/api/updates/' + sessionId, {
+ body: JSON.stringify({ subscribeTo: currentPage!.dmId || currentPageID }),
+ method: 'POST'
+ });
+ }
+
+ previousSubscription = currentPageID;
}
getMessages();
@@ -68,6 +91,7 @@
id: ServerID.parse(z.id),
name: z.name,
ownerId: z.ownerId,
+
image: 'https://api.dicebear.com/7.x/pixel-art/svg?seed=' + z.name
};
});
@@ -95,6 +119,7 @@
username: friend.username,
status: status.status,
statusMessage: status.statusMessage,
+ dmId: friend.dmId,
image: 'https://api.dicebear.com/7.x/pixel-art/svg?seed=' + friend.username
};
})
@@ -109,11 +134,12 @@
sse.addEventListener('message', (e) => {
const json = JSON.parse(e.data) as
- | { type: 'connected' }
+ | { type: 'connected'; sessionId: string }
| { type: 'status'; id: string; status: 1 | 2 | 3 };
if (json.type == 'connected') {
- console.log('SSE connected.');
+ console.log('SSE connected. We are sessionID ' + json.sessionId);
+ sessionId = json.sessionId;
}
if (json.type == 'status') {
@@ -122,6 +148,10 @@
friend.status = json.status;
}
}
+
+ if (json.type == 'message') {
+ messages.push(json.message);
+ }
});
});
@@ -203,5 +233,29 @@
{/if}
{/each}
+
+ {#if currentPageID && currentPage}
+
+
+ {/if}