diff --git a/api/src/routes/channels/#channel_id/invites.ts b/api/src/routes/channels/#channel_id/invites.ts
index 5fef136d..6155ef7d 100644
--- a/api/src/routes/channels/#channel_id/invites.ts
+++ b/api/src/routes/channels/#channel_id/invites.ts
@@ -45,7 +45,8 @@ router.post("/", route({ body: "InviteCreateSchema", permission: "CREATE_INSTANT
channel_id: channel_id,
inviter_id: user_id
}).save();
- const data = invite.toJSON();
+ //TODO: check this, removed toJSON call
+ const data = JSON.parse(JSON.stringify(invite));
data.inviter = await User.getPublicUser(req.user_id);
data.guild = await Guild.findOne({ where: { id: guild_id } });
data.channel = channel;
diff --git a/api/src/routes/guilds/#guild_id/index.ts b/api/src/routes/guilds/#guild_id/index.ts
index 2d748d61..263579e7 100644
--- a/api/src/routes/guilds/#guild_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/index.ts
@@ -61,7 +61,8 @@ router.patch("/", route({ body: "GuildUpdateSchema"}), async (req: Request, res:
// TODO: check if body ids are valid
guild.assign(body);
- const data = guild.toJSON();
+ //TODO: check this, removed toJSON call
+ const data = JSON.parse(JSON.stringify(guild));
// TODO: guild hashes
// TODO: fix vanity_url_code, template_id
delete data.vanity_url_code;
diff --git a/api/src/util/handlers/Instance.ts b/api/src/util/handlers/Instance.ts
index 6bddfa98..7c337270 100644
--- a/api/src/util/handlers/Instance.ts
+++ b/api/src/util/handlers/Instance.ts
@@ -1,4 +1,5 @@
import { Config, Guild, Session } from "@fosscord/util";
+import { createQueryBuilder } from "typeorm";
export async function initInstance() {
// TODO: clean up database and delete tombstone data
@@ -9,7 +10,7 @@ export async function initInstance() {
const { autoJoin } = Config.get().guild;
if (autoJoin.enabled && !autoJoin.guilds?.length) {
- let guild = await Guild.findOne({});
+ let guild = await Guild.findOne({where: {}, order: {id: "ASC"}});
if (guild) {
// @ts-ignore
await Config.set({ guild: { autoJoin: { guilds: [guild.id] } } });
diff --git a/api/src/util/handlers/Message.ts b/api/src/util/handlers/Message.ts
index 80012260..7035bc5c 100644
--- a/api/src/util/handlers/Message.ts
+++ b/api/src/util/handlers/Message.ts
@@ -201,9 +201,10 @@ export async function postHandleMessage(message: Message) {
export async function sendMessage(opts: MessageOptions) {
const message = await handleMessage({ ...opts, timestamp: new Date() });
+ //TODO: check this, removed toJSON call
await Promise.all([
Message.insert(message),
- emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data: message.toJSON() } as MessageCreateEvent)
+ emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data: message } as MessageCreateEvent)
]);
postHandleMessage(message).catch((e) => {}); // no await as it should catch error non-blockingly
diff --git a/api/src/util/index.ts b/api/src/util/index.ts
index ac439371..b3c7559f 100644
--- a/api/src/util/index.ts
+++ b/api/src/util/index.ts
@@ -1,9 +1,9 @@
+export * from "./entities/AssetCacheItem";
+export * from "./handlers/Message";
+export * from "./handlers/route";
+export * from "./handlers/Voice";
export * from "./utility/Base64";
export * from "./utility/ipAddress";
-export * from "./handlers/Message";
export * from "./utility/passwordStrength";
export * from "./utility/RandomInviteID";
-export * from "./handlers/route";
-export * from "./utility/String";
-export * from "./handlers/Voice";
-export * from "./entities/AssetCacheItem";
\ No newline at end of file
+export * from "./utility/String";
\ No newline at end of file
|