diff --git a/src/util/config/Config.ts b/src/util/config/Config.ts
index 7fe879db..7549b8b6 100644
--- a/src/util/config/Config.ts
+++ b/src/util/config/Config.ts
@@ -22,6 +22,7 @@ import {
ComponentConfiguration,
DefaultsConfiguration,
EmailConfiguration,
+ EmbedConfiguration,
EndpointConfiguration,
ExternalTokensConfiguration,
GeneralConfiguration,
@@ -61,4 +62,5 @@ export class ConfigValue {
user: UserConfiguration = new UserConfiguration();
offload: OffloadConfiguration = new OffloadConfiguration();
components = new ComponentConfiguration();
+ embeds = new EmbedConfiguration();
}
diff --git a/src/util/config/types/EmbedConfiguration.ts b/src/util/config/types/EmbedConfiguration.ts
new file mode 100644
index 00000000..94300831
--- /dev/null
+++ b/src/util/config/types/EmbedConfiguration.ts
@@ -0,0 +1,29 @@
+/*
+ Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2025 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/>.
+*/
+
+export class EmbedConfiguration {
+ defaultUserAgent: string | null = null;
+
+ youtube = new YoutubeEmbedConfiguration();
+}
+
+export class YoutubeEmbedConfiguration {
+ useCurlUserAgent: boolean = false;
+ userAgent: string | null = null;
+ cookie: string | null = null;
+}
diff --git a/src/util/config/types/index.ts b/src/util/config/types/index.ts
index 9e689c24..872b590b 100644
--- a/src/util/config/types/index.ts
+++ b/src/util/config/types/index.ts
@@ -37,3 +37,4 @@ export * from "./subconfigurations";
export * from "./TemplateConfiguration";
export * from "./UsersConfiguration";
export * from "./ComponentConfiguration";
+export * from "./EmbedConfiguration";
diff --git a/src/util/entities/EmbedCache.ts b/src/util/entities/EmbedCache.ts
index a9ffd063..6a773805 100644
--- a/src/util/entities/EmbedCache.ts
+++ b/src/util/entities/EmbedCache.ts
@@ -27,12 +27,11 @@ export class EmbedCache extends BaseClass {
@Column()
url: string;
- @Column({ type: "simple-json" })
- embed: Embed;
+ @Column({ type: "simple-json", nullable: true })
+ embed?: Embed;
- // TODO: store all returned embed objects from a handler
- // @Column({ type: "simple-json" })
- // embeds: Embed[];
+ @Column({ type: "simple-json", nullable: true })
+ embeds?: Embed[];
@Column({ name: "created_at", type: "timestamp with time zone" })
createdAt: Date;
diff --git a/src/util/migration/postgres/1772404321403-EmbedCacheMultiEmbed.ts b/src/util/migration/postgres/1772404321403-EmbedCacheMultiEmbed.ts
new file mode 100644
index 00000000..55e80fdc
--- /dev/null
+++ b/src/util/migration/postgres/1772404321403-EmbedCacheMultiEmbed.ts
@@ -0,0 +1,16 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class EmbedCacheCreatedAt1772404321403 implements MigrationInterface {
+ name = "EmbedCacheCreatedAt1772404321403";
+
+ public async up(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query(`ALTER TABLE "embed_cache" ALTER COLUMN "embed" DROP NOT NULL;`);
+ await queryRunner.query(`ALTER TABLE "embed_cache" ADD "embeds" text NULL;`);
+ }
+
+ public async down(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query(`ALTER TABLE "embed_cache" DROP COLUMN "embeds"`);
+ await queryRunner.query(`UPDATE "embed_cache" SET "embed" = '{}' WHERE "embed" IS NULL;`);
+ await queryRunner.query(`ALTER TABLE "embed_cache" ALTER COLUMN "embed" SET NOT NULL;`);
+ }
+}
|