mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-22 12:52:30 +00:00
webhook fixes & username/avatar property for msg
This commit is contained in:
1 parent
99d9bf563f
commit
e7a98b6c46
9 files changed
+172
-44
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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`");
|
||||
}
|
||||
}
|
||||
@@ -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`");
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user