mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 04:32:35 +01:00
Add new message flags once again
This commit is contained in:
parent
0ac8888d41
commit
c52d6c49a3
@ -56,6 +56,7 @@ router.post(
|
|||||||
edited_timestamp: null,
|
edited_timestamp: null,
|
||||||
flags: 1,
|
flags: 1,
|
||||||
components: [],
|
components: [],
|
||||||
|
poll: {},
|
||||||
}).status(200);
|
}).status(200);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -162,6 +162,7 @@ router.get(
|
|||||||
edited_timestamp: x.edited_timestamp,
|
edited_timestamp: x.edited_timestamp,
|
||||||
flags: x.flags,
|
flags: x.flags,
|
||||||
components: x.components,
|
components: x.components,
|
||||||
|
poll: x.poll,
|
||||||
hit: true,
|
hit: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
@ -218,6 +218,9 @@ export class Message extends BaseClass {
|
|||||||
@Column({ type: "simple-json", nullable: true })
|
@Column({ type: "simple-json", nullable: true })
|
||||||
components?: MessageComponent[];
|
components?: MessageComponent[];
|
||||||
|
|
||||||
|
@Column({ type: "simple-json", nullable: true })
|
||||||
|
poll?: Poll[];
|
||||||
|
|
||||||
toJSON(): Message {
|
toJSON(): Message {
|
||||||
return {
|
return {
|
||||||
...this,
|
...this,
|
||||||
@ -238,6 +241,7 @@ export class Message extends BaseClass {
|
|||||||
activity: this.activity ?? undefined,
|
activity: this.activity ?? undefined,
|
||||||
application: this.application ?? undefined,
|
application: this.application ?? undefined,
|
||||||
components: this.components ?? undefined,
|
components: this.components ?? undefined,
|
||||||
|
poll: this.poll ?? undefined,
|
||||||
content: this.content ?? "",
|
content: this.content ?? "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -249,6 +253,7 @@ export interface MessageComponent {
|
|||||||
label?: string;
|
label?: string;
|
||||||
emoji?: PartialEmoji;
|
emoji?: PartialEmoji;
|
||||||
custom_id?: string;
|
custom_id?: string;
|
||||||
|
sku_id?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
components: MessageComponent[];
|
components: MessageComponent[];
|
||||||
@ -327,3 +332,32 @@ export interface AllowedMentions {
|
|||||||
users?: string[];
|
users?: string[];
|
||||||
replied_user?: boolean;
|
replied_user?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Poll {
|
||||||
|
question: PollMedia;
|
||||||
|
answers: PollAnswer[];
|
||||||
|
expiry: Date;
|
||||||
|
allow_multiselect: boolean;
|
||||||
|
results?: PollResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PollMedia {
|
||||||
|
text?: string;
|
||||||
|
emoji?: PartialEmoji;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PollAnswer {
|
||||||
|
answer_id?: string;
|
||||||
|
poll_media: PollMedia;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PollResult {
|
||||||
|
is_finalized: boolean;
|
||||||
|
answer_counts: PollAnswerCount[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PollAnswerCount {
|
||||||
|
id: string;
|
||||||
|
count: number;
|
||||||
|
me_voted: boolean;
|
||||||
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class MessagePollObject1720157926878 implements MigrationInterface {
|
||||||
|
name = "MessagePollObject1720157926878";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE `messages` ADD `poll` text NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `poll`");
|
||||||
|
}
|
||||||
|
}
|
13
src/util/migration/mysql/1720157926878-messagePollObject.ts
Normal file
13
src/util/migration/mysql/1720157926878-messagePollObject.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class MessagePollObject1720157926878 implements MigrationInterface {
|
||||||
|
name = "MessagePollObject1720157926878";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE `messages` ADD `poll` text NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `poll`");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class MessagePollObject1720157926878 implements MigrationInterface {
|
||||||
|
name = "MessagePollObject1720157926878";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE messages ADD poll text NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query("ALTER TABLE messages DROP COLUMN poll");
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Embed } from "@spacebar/util";
|
import { Embed, MessageComponent, PollAnswer, PollMedia } from "@spacebar/util";
|
||||||
|
|
||||||
type Attachment = {
|
type Attachment = {
|
||||||
id: string;
|
id: string;
|
||||||
@ -54,6 +54,21 @@ export interface MessageCreateSchema {
|
|||||||
**/
|
**/
|
||||||
attachments?: Attachment[];
|
attachments?: Attachment[];
|
||||||
sticker_ids?: string[];
|
sticker_ids?: string[];
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
components?: MessageComponent[];
|
||||||
components?: any[];
|
// TODO: Fix TypeScript errors in src\api\util\handlers\Message.ts once this is enabled
|
||||||
|
//poll?: PollCreationSchema;
|
||||||
|
enforce_nonce?: boolean; // For Discord compatibility, it's the default behavior here
|
||||||
|
applied_tags?: string[]; // Not implemented yet, for webhooks in forums
|
||||||
|
thread_name?: string; // Not implemented yet, for webhooks
|
||||||
|
avatar_url?: string; // Not implemented yet, for webhooks
|
||||||
|
}
|
||||||
|
|
||||||
|
// TypeScript complains once this is used above
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
interface PollCreationSchema {
|
||||||
|
question: PollMedia;
|
||||||
|
answers: PollAnswer[];
|
||||||
|
duration?: number;
|
||||||
|
allow_multiselect?: boolean;
|
||||||
|
layout_type?: number;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
import {
|
import {
|
||||||
Attachment,
|
Attachment,
|
||||||
Embed,
|
Embed,
|
||||||
|
MessageComponent,
|
||||||
MessageType,
|
MessageType,
|
||||||
|
Poll,
|
||||||
PublicUser,
|
PublicUser,
|
||||||
Role,
|
Role,
|
||||||
} from "../../entities";
|
} from "../../entities";
|
||||||
@ -40,7 +42,8 @@ export interface GuildMessagesSearchMessage {
|
|||||||
timestamp: string;
|
timestamp: string;
|
||||||
edited_timestamp: string | null;
|
edited_timestamp: string | null;
|
||||||
flags: number;
|
flags: number;
|
||||||
components: unknown[];
|
components: MessageComponent[];
|
||||||
|
poll: Poll;
|
||||||
hit: true;
|
hit: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user