fix: move types to schema
This commit is contained in:
parent
a94f84dd72
commit
a2322c58aa
@ -230,10 +230,9 @@ router.get(
|
||||
});
|
||||
|
||||
await ret
|
||||
.filter((x) => x.interaction_metadata && !x.interaction_metadata.user)
|
||||
.forEachAsync(async (x) => {
|
||||
x.interaction_metadata!.user = await User.findOne({ where: { id: x.interaction_metadata!.user_id } });
|
||||
x.interaction!.user = await User.findOne({ where: { id: x.interaction_metadata!.user_id } });
|
||||
.filter((x: MessageCreateSchema) => x.interaction_metadata && !x.interaction_metadata.user)
|
||||
.forEachAsync(async (x: MessageCreateSchema) => {
|
||||
x.interaction_metadata!.user = x.interaction!.user = await User.findOneOrFail({ where: { id: (x as Message).interaction_metadata!.user_id } });
|
||||
});
|
||||
|
||||
// polyfill message references for old messages
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
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 = {
|
||||
id: string;
|
||||
@ -28,7 +29,7 @@ export type MessageCreateCloudAttachment = {
|
||||
filename: string;
|
||||
uploaded_filename: string;
|
||||
original_content_type?: string;
|
||||
}
|
||||
};
|
||||
|
||||
export interface MessageCreateSchema {
|
||||
type?: number;
|
||||
@ -68,6 +69,8 @@ export interface MessageCreateSchema {
|
||||
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
|
||||
interaction?: MessageInteractionSchema;
|
||||
interaction_metadata?: MessageInteractionSchema;
|
||||
}
|
||||
|
||||
// TypeScript complains once this is used above
|
||||
@ -78,3 +81,10 @@ export interface PollCreationSchema {
|
||||
allow_multiselect?: boolean;
|
||||
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 })
|
||||
interaction?: {
|
||||
user: User | null;
|
||||
id: string;
|
||||
type: InteractionType;
|
||||
name: string;
|
||||
@ -182,7 +181,6 @@ export class Message extends BaseClass {
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
interaction_metadata?: {
|
||||
user: User | null;
|
||||
id: string;
|
||||
type: InteractionType;
|
||||
user_id: string;
|
||||
|
||||
Reference in New Issue
Block a user