summary refs log tree commit diff
path: root/api/src/util
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-07 02:52:09 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-09 23:28:27 +0200
commit365abc36dd3b41680527bcf613013bb4999b613d (patch)
treef46b9c12a0c89de24af1a862db414c44d30e8b3e /api/src/util
parentResolve changes undone by rebasing from master (diff)
downloadserver-365abc36dd3b41680527bcf613013bb4999b613d.tar.xz
Switch to migrations fully
Diffstat (limited to 'api/src/util')
-rw-r--r--api/src/util/handlers/Instance.ts3
-rw-r--r--api/src/util/handlers/Message.ts3
-rw-r--r--api/src/util/index.ts10
3 files changed, 9 insertions, 7 deletions
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