From 25aa1eeb37420ac75dd4ab031776010240b641d3 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 10 Oct 2021 16:11:40 +0200 Subject: [PATCH 1/2] :bug: fix Identify --- gateway/src/opcodes/Identify.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts index 4470857f..673dde9d 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts @@ -94,9 +94,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { // @ts-ignore x.channel.recipients = x.channel.recipients?.map((x) => x.user); //TODO is this needed? check if users in group dm that are not friends are sent in the READY event - users = users.concat( - x.channel.recipients?.map((x) => x.user) as User[] - ); + users = users.concat(x.channel.recipients as unknown as User[]); if (x.channel.isDm()) { x.channel.recipients = x.channel.recipients!.filter( (x) => x.id !== this.user_id From 0cabe8ed4c4cf8ce5ff1bca5bac1454fecfde77e Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 10 Oct 2021 18:31:04 +0200 Subject: [PATCH 2/2] :art: update migration script --- util/src/migrations/migrate_db_engine.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/util/src/migrations/migrate_db_engine.ts b/util/src/migrations/migrate_db_engine.ts index 33024a8d..527e7b53 100644 --- a/util/src/migrations/migrate_db_engine.ts +++ b/util/src/migrations/migrate_db_engine.ts @@ -15,7 +15,6 @@ import { Invite, Member, Message, - RateLimit, ReadState, Recipient, Relationship, @@ -30,7 +29,7 @@ import { } from ".."; async function main() { - if (!process.env.FROM) throw new Error("FROM database env connection string not set"); + if (!process.env.TO) throw new Error("TO database env connection string not set"); // manually arrange them because of foreign key const entities = [ @@ -59,10 +58,14 @@ async function main() { const newDB = await initDatabase(); + const type = process.env.TO.includes("://") ? process.env.TO.split(":")[0]?.replace("+srv", "") : "sqlite"; + const isSqlite = type.includes("sqlite"); + // @ts-ignore const oldDB = await createConnection({ - type: process.env.FROM.split(":")[0]?.replace("+srv", ""), - url: process.env.FROM, + type, + url: isSqlite ? undefined : process.env.TO, + database: isSqlite ? process.env.TO : undefined, entities, name: "old", }); @@ -72,14 +75,13 @@ async function main() { for (const e of entities) { const entity = e as EntityTarget; const entries = await oldDB.manager.find(entity); - //@ts-ignore - console.log("migrated " + entries.length + " " + entity.name); + // @ts-ignore + console.log("migrating " + entries.length + " " + entity.name + " ..."); for (const entry of entries) { console.log(i++); if (entry instanceof User) { - console.log("instance of User"); if (entry.bio == null) entry.bio = ""; if (entry.rights == null) entry.rights = "0"; if (entry.disabled == null) entry.disabled = false; @@ -116,7 +118,7 @@ async function main() { // } } // @ts-ignore - console.log("migrated all " + entity.name); + console.log("migrated " + entries.length + " " + entity.name); } } catch (error) { console.error((error as any).message);