fix: add user object on interaction and interaction_metadata for messages
This commit is contained in:
parent
4b5db1c2f4
commit
a94f84dd72
@ -229,17 +229,25 @@ router.get(
|
|||||||
return x;
|
return x;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 } });
|
||||||
|
});
|
||||||
|
|
||||||
// polyfill message references for old messages
|
// polyfill message references for old messages
|
||||||
await ret.filter((msg) => msg.message_reference && !msg.referenced_message?.id).forEachAsync(async (msg) => {
|
await ret
|
||||||
const whereOptions: { id: string; guild_id?: string; channel_id?: string } = {
|
.filter((msg) => msg.message_reference && !msg.referenced_message?.id)
|
||||||
id: msg.message_reference!.message_id,
|
.forEachAsync(async (msg) => {
|
||||||
};
|
const whereOptions: { id: string; guild_id?: string; channel_id?: string } = {
|
||||||
if (msg.message_reference!.guild_id) whereOptions.guild_id = msg.message_reference!.guild_id;
|
id: msg.message_reference!.message_id,
|
||||||
if (msg.message_reference!.channel_id) whereOptions.channel_id = msg.message_reference!.channel_id;
|
};
|
||||||
|
if (msg.message_reference!.guild_id) whereOptions.guild_id = msg.message_reference!.guild_id;
|
||||||
|
if (msg.message_reference!.channel_id) whereOptions.channel_id = msg.message_reference!.channel_id;
|
||||||
|
|
||||||
msg.referenced_message = await Message.findOne({ where: whereOptions, relations: ["author", "mentions", "mention_roles", "mention_channels"] });
|
msg.referenced_message = await Message.findOne({ where: whereOptions, relations: ["author", "mentions", "mention_roles", "mention_channels"] });
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.json(ret);
|
return res.json(ret);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -174,6 +174,7 @@ 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;
|
||||||
@ -181,6 +182,7 @@ 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