diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts
index b519099ab..86238e532 100644
--- a/src/util/entities/Message.ts
+++ b/src/util/entities/Message.ts
@@ -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/>.
*/
@@ -218,6 +218,12 @@ export class Message extends BaseClass {
@Column({ type: "simple-json", nullable: true })
components?: MessageComponent[];
+ @Column({ nullable: true })
+ username?: string;
+
+ @Column({ nullable: true })
+ avatar?: string;
+
toJSON(): Message {
return {
...this,
@@ -234,7 +240,12 @@ export class Message extends BaseClass {
reactions: this.reactions ?? undefined,
sticker_items: this.sticker_items ?? undefined,
message_reference: this.message_reference ?? undefined,
- author: this.author?.toPublicUser() ?? undefined,
+ author: {
+ ...this.author?.toPublicUser() ?? undefined,
+ // Webhooks
+ username: this.username ?? this.author?.username,
+ avatar: this.avatar ?? this.author?.avatar,
+ },
activity: this.activity ?? undefined,
application: this.application ?? undefined,
components: this.components ?? undefined,
diff --git a/src/util/entities/Webhook.ts b/src/util/entities/Webhook.ts
index 91498a22c..b7fba53a1 100644
--- a/src/util/entities/Webhook.ts
+++ b/src/util/entities/Webhook.ts
@@ -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/>.
*/
@@ -35,7 +35,7 @@ export class Webhook extends BaseClass {
type: WebhookType;
@Column({ nullable: true })
- name?: string;
+ name: string;
@Column({ nullable: true })
avatar?: string;
diff --git a/src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts b/src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts
new file mode 100644
index 000000000..ccbe689ad
--- /dev/null
+++ b/src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts
@@ -0,0 +1,15 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class WebhookMessageProperties1721298824927 implements MigrationInterface {
+ name = "WebhookMessageProperties1721298824927";
+
+ public async up(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query("ALTER TABLE `messages` ADD `username` text NULL");
+ await queryRunner.query("ALTER TABLE `messages` ADD `avatar` text NULL");
+ }
+
+ public async down(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `username`");
+ await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `avatar`");
+ }
+}
diff --git a/src/util/migration/mysql/1721298824927-webhookMessageProperties.ts b/src/util/migration/mysql/1721298824927-webhookMessageProperties.ts
new file mode 100644
index 000000000..ccbe689ad
--- /dev/null
+++ b/src/util/migration/mysql/1721298824927-webhookMessageProperties.ts
@@ -0,0 +1,15 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class WebhookMessageProperties1721298824927 implements MigrationInterface {
+ name = "WebhookMessageProperties1721298824927";
+
+ public async up(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query("ALTER TABLE `messages` ADD `username` text NULL");
+ await queryRunner.query("ALTER TABLE `messages` ADD `avatar` text NULL");
+ }
+
+ public async down(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `username`");
+ await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `avatar`");
+ }
+}
diff --git a/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts b/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts
new file mode 100644
index 000000000..46c507d43
--- /dev/null
+++ b/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts
@@ -0,0 +1,15 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class WebhookMessageProperties1721298824927 implements MigrationInterface {
+ name = "WebhookMessageProperties1721298824927";
+
+ public async up(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query("ALTER TABLE messages ADD username text NULL");
+ await queryRunner.query("ALTER TABLE messages ADD avatar text NULL");
+ }
+
+ public async down(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query("ALTER TABLE messages DROP COLUMN username");
+ await queryRunner.query("ALTER TABLE messages DROP COLUMN avatar");
+ }
+}
|