fix: move types to schema
This commit is contained in:
parent
a94f84dd72
commit
a2322c58aa
@ -230,10 +230,9 @@ router.get(
|
|||||||
});
|
});
|
||||||
|
|
||||||
await ret
|
await ret
|
||||||
.filter((x) => x.interaction_metadata && !x.interaction_metadata.user)
|
.filter((x: MessageCreateSchema) => x.interaction_metadata && !x.interaction_metadata.user)
|
||||||
.forEachAsync(async (x) => {
|
.forEachAsync(async (x: MessageCreateSchema) => {
|
||||||
x.interaction_metadata!.user = await User.findOne({ where: { id: x.interaction_metadata!.user_id } });
|
x.interaction_metadata!.user = x.interaction!.user = await User.findOneOrFail({ where: { id: (x as Message).interaction_metadata!.user_id } });
|
||||||
x.interaction!.user = await User.findOne({ where: { id: x.interaction_metadata!.user_id } });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// polyfill message references for old messages
|
// polyfill message references for old messages
|
||||||
|
|||||||
@ -16,7 +16,8 @@
|
|||||||
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 { ActionRowComponent, Embed, PollAnswer, PollMedia } from "@spacebar/schemas"
|
import { InteractionType } from "@spacebar/util";
|
||||||
|
import { ActionRowComponent, Embed, PollAnswer, PollMedia, PublicUser } from "@spacebar/schemas";
|
||||||
|
|
||||||
export type MessageCreateAttachment = {
|
export type MessageCreateAttachment = {
|
||||||
id: string;
|
id: string;
|
||||||
@ -28,7 +29,7 @@ export type MessageCreateCloudAttachment = {
|
|||||||
filename: string;
|
filename: string;
|
||||||
uploaded_filename: string;
|
uploaded_filename: string;
|
||||||
original_content_type?: string;
|
original_content_type?: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface MessageCreateSchema {
|
export interface MessageCreateSchema {
|
||||||
type?: number;
|
type?: number;
|
||||||
@ -68,6 +69,8 @@ export interface MessageCreateSchema {
|
|||||||
applied_tags?: string[]; // Not implemented yet, for webhooks in forums
|
applied_tags?: string[]; // Not implemented yet, for webhooks in forums
|
||||||
thread_name?: string; // Not implemented yet, for webhooks
|
thread_name?: string; // Not implemented yet, for webhooks
|
||||||
avatar_url?: string; // Not implemented yet, for webhooks
|
avatar_url?: string; // Not implemented yet, for webhooks
|
||||||
|
interaction?: MessageInteractionSchema;
|
||||||
|
interaction_metadata?: MessageInteractionSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeScript complains once this is used above
|
// TypeScript complains once this is used above
|
||||||
@ -78,3 +81,10 @@ export interface PollCreationSchema {
|
|||||||
allow_multiselect?: boolean;
|
allow_multiselect?: boolean;
|
||||||
layout_type?: number;
|
layout_type?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface MessageInteractionSchema {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
type: InteractionType;
|
||||||
|
user?: PublicUser; // It has to be optional cause LSP gives an errors for some reason
|
||||||
|
}
|
||||||
|
|||||||
@ -174,7 +174,6 @@ export class Message extends BaseClass {
|
|||||||
|
|
||||||
@Column({ type: "simple-json", nullable: true })
|
@Column({ type: "simple-json", nullable: true })
|
||||||
interaction?: {
|
interaction?: {
|
||||||
user: User | null;
|
|
||||||
id: string;
|
id: string;
|
||||||
type: InteractionType;
|
type: InteractionType;
|
||||||
name: string;
|
name: string;
|
||||||
@ -182,7 +181,6 @@ export class Message extends BaseClass {
|
|||||||
|
|
||||||
@Column({ type: "simple-json", nullable: true })
|
@Column({ type: "simple-json", nullable: true })
|
||||||
interaction_metadata?: {
|
interaction_metadata?: {
|
||||||
user: User | null;
|
|
||||||
id: string;
|
id: string;
|
||||||
type: InteractionType;
|
type: InteractionType;
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user