fix: process Discord DM reactions instead of silently dropping them

This commit is contained in:
Marcus Castro
2026-02-06 10:36:16 -03:00
committed by Shadow
parent d9f3d569a2
commit 888f7dbbd8
2 changed files with 192 additions and 8 deletions

View File

@@ -188,10 +188,6 @@ async function handleDiscordReactionEvent(params: {
if (!user || user.bot) {
return;
}
if (!data.guild_id) {
return;
}
const guildInfo = resolveDiscordGuildEntry({
guild: data.guild ?? undefined,
guildEntries,
@@ -207,6 +203,8 @@ async function handleDiscordReactionEvent(params: {
const channelName = "name" in channel ? (channel.name ?? undefined) : undefined;
const channelSlug = channelName ? normalizeDiscordSlug(channelName) : "";
const channelType = "type" in channel ? channel.type : undefined;
const isDirectMessage = channelType === ChannelType.DM;
const isGroupDm = channelType === ChannelType.GroupDM;
const isThreadChannel =
channelType === ChannelType.PublicThread ||
channelType === ChannelType.PrivateThread ||
@@ -262,7 +260,8 @@ async function handleDiscordReactionEvent(params: {
const emojiLabel = formatDiscordReactionEmoji(data.emoji);
const actorLabel = formatDiscordUserTag(user);
const guildSlug =
guildInfo?.slug || (data.guild?.name ? normalizeDiscordSlug(data.guild.name) : data.guild_id);
guildInfo?.slug ||
(data.guild?.name ? normalizeDiscordSlug(data.guild.name) : (data.guild_id ?? "dm"));
const channelLabel = channelSlug
? `#${channelSlug}`
: channelName
@@ -276,7 +275,10 @@ async function handleDiscordReactionEvent(params: {
channel: "discord",
accountId: params.accountId,
guildId: data.guild_id ?? undefined,
peer: { kind: "channel", id: data.channel_id },
peer: {
kind: isDirectMessage ? "dm" : isGroupDm ? "group" : "channel",
id: isDirectMessage ? user.id : data.channel_id,
},
parentPeer: parentId ? { kind: "channel", id: parentId } : undefined,
});
enqueueSystemEvent(text, {