Skip to content

Commit

Permalink
Merge pull request spacebarchat#1178 from DEVTomatoCake/fix/1154-mysq…
Browse files Browse the repository at this point in the history
…l-charset
  • Loading branch information
MaddyUnderStars authored Aug 22, 2024
2 parents 08fc90a + dfbbef3 commit 9bcc178
Show file tree
Hide file tree
Showing 39 changed files with 286 additions and 131 deletions.
12 changes: 8 additions & 4 deletions src/util/entities/Application.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand All @@ -20,8 +20,12 @@ import { Column, Entity, JoinColumn, ManyToOne, OneToOne } from "typeorm";
import { BaseClass } from "./BaseClass";
import { Team } from "./Team";
import { User } from "./User";
import { dbEngine } from "../util/Database";

@Entity("applications")
@Entity({
name: "applications",
engine: dbEngine,
})
export class Application extends BaseClass {
@Column()
name: string;
Expand Down
12 changes: 8 additions & 4 deletions src/util/entities/Attachment.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand All @@ -27,8 +27,12 @@ import {
import { URL } from "url";
import { deleteFile } from "../util/cdn";
import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";

@Entity("attachments")
@Entity({
name: "attachments",
engine: dbEngine,
})
export class Attachment extends BaseClass {
@Column()
filename: string; // name of file attached
Expand Down
12 changes: 8 additions & 4 deletions src/util/entities/AuditLog.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand All @@ -20,6 +20,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { ChannelPermissionOverwrite } from "./Channel";
import { User } from "./User";
import { dbEngine } from "../util/Database";

export enum AuditLogEvents {
// guild level
Expand Down Expand Up @@ -111,7 +112,10 @@ export enum AuditLogEvents {
ROUTE_UPDATE = 226,
}

@Entity("audit_logs")
@Entity({
name: "audit_logs",
engine: dbEngine,
})
export class AuditLog extends BaseClass {
@JoinColumn({ name: "target_id" })
@ManyToOne(() => User)
Expand Down
12 changes: 8 additions & 4 deletions src/util/entities/BackupCodes.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand All @@ -20,8 +20,12 @@ import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
import { BaseClass } from "./BaseClass";
import { User } from "./User";
import crypto from "crypto";
import { dbEngine } from "../util/Database";

@Entity("backup_codes")
@Entity({
name: "backup_codes",
engine: dbEngine,
})
export class BackupCode extends BaseClass {
@JoinColumn({ name: "user_id" })
@ManyToOne(() => User, { onDelete: "CASCADE" })
Expand Down
12 changes: 8 additions & 4 deletions src/util/entities/Badge.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { Column, Entity } from "typeorm";
import { BaseClassWithoutId } from "./BaseClass";
import { dbEngine } from "../util/Database";

@Entity("badges")
@Entity({
name: "badges",
engine: dbEngine,
})
export class Badge extends BaseClassWithoutId {
@Column({ primary: true })
id: string;
Expand Down
12 changes: 8 additions & 4 deletions src/util/entities/Ban.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand All @@ -20,8 +20,12 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild";
import { User } from "./User";
import { dbEngine } from "../util/Database";

@Entity("bans")
@Entity({
name: "bans",
engine: dbEngine,
})
export class Ban extends BaseClass {
@Column({ nullable: true })
@RelationId((ban: Ban) => ban.user)
Expand Down
6 changes: 5 additions & 1 deletion src/util/entities/Categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
import { dbEngine } from "../util/Database";

// TODO: categories:
// [{
Expand All @@ -33,7 +34,10 @@ import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
// }]
// Also populate discord default categories

@Entity("categories")
@Entity({
name: "categories",
engine: dbEngine,
})
export class Categories extends BaseClassWithoutId {
// Not using snowflake

Expand Down
6 changes: 5 additions & 1 deletion src/util/entities/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { Recipient } from "./Recipient";
import { PublicUserProjection, User } from "./User";
import { VoiceState } from "./VoiceState";
import { Webhook } from "./Webhook";
import { dbEngine } from "../util/Database";

export enum ChannelType {
GUILD_TEXT = 0, // a text channel within a guild
Expand All @@ -69,7 +70,10 @@ export enum ChannelType {
UNHANDLED = 255, // unhandled unowned pass-through channel type
}

@Entity("channels")
@Entity({
name: "channels",
engine: dbEngine,
})
export class Channel extends BaseClass {
@Column()
created_at: Date;
Expand Down
12 changes: 8 additions & 4 deletions src/util/entities/ClientRelease.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { Column, Entity } from "typeorm";
import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";

@Entity("client_release")
@Entity({
name: "client_release",
engine: dbEngine,
})
export class Release extends BaseClass {
@Column()
name: string;
Expand Down
12 changes: 8 additions & 4 deletions src/util/entities/Config.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
import { dbEngine } from "../util/Database";

@Entity("config")
@Entity({
name: "config",
engine: dbEngine,
})
export class ConfigEntity extends BaseClassWithoutId {
@PrimaryIdColumn()
key: string;
Expand Down
12 changes: 8 additions & 4 deletions src/util/entities/ConnectedAccount.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand All @@ -20,13 +20,17 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { ConnectedAccountTokenData } from "../interfaces";
import { BaseClass } from "./BaseClass";
import { User } from "./User";
import { dbEngine } from "../util/Database";

export type PublicConnectedAccount = Pick<
ConnectedAccount,
"name" | "type" | "verified"
>;

@Entity("connected_accounts")
@Entity({
name: "connected_accounts",
engine: dbEngine,
})
export class ConnectedAccount extends BaseClass {
@Column()
external_id: string;
Expand Down
12 changes: 8 additions & 4 deletions src/util/entities/ConnectionConfigEntity.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
import { dbEngine } from "../util/Database";

@Entity("connection_config")
@Entity({
name: "connection_config",
engine: dbEngine,
})
export class ConnectionConfigEntity extends BaseClassWithoutId {
@PrimaryIdColumn()
key: string;
Expand Down
Loading

0 comments on commit 9bcc178

Please sign in to comment.