Skip to content

Commit 3779f15

Browse files
daveclaude
andcommitted
fix: only drop unknown-channel posts after API fallback also fails
Codex review: dropping immediately when payload.data.channel_type is missing lost messages that the API lookup could have recovered. Now the early guard only drops when both the event field AND the resolveChannelInfo API fallback return unknown. The second resolveChannelInfo call hits the cache (same tick) so no extra network request is made. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0eb76ff commit 3779f15

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

extensions/mattermost/src/mattermost/monitor.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,12 +1020,20 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
10201020
}
10211021
// Check channel type before marking the message as seen, so that a
10221022
// transient unknown-channel post doesn't poison the dedup tracker.
1023+
// If the event has no channel_type, fall back to the API — but if that
1024+
// also returns nothing, drop the post.
10231025
const channelTypeFromEvent = payload.data?.channel_type;
10241026
if (mapMattermostChannelTypeToChatType(channelTypeFromEvent) === "unknown") {
1025-
logVerboseMessage(
1026-
`mattermost: drop post (cannot determine channel type for ${channelId}, post=${post.id ?? "?"})`,
1027-
);
1028-
return;
1027+
const channelInfoFallback = await resolveChannelInfo(channelId);
1028+
if (mapMattermostChannelTypeToChatType(channelInfoFallback?.type) === "unknown") {
1029+
logVerboseMessage(
1030+
`mattermost: drop post (cannot determine channel type for ${channelId}, post=${post.id ?? "?"})`,
1031+
);
1032+
return;
1033+
}
1034+
// channelInfoFallback.type is now set; continue with the normal path below.
1035+
// (resolveChannelInfo result is cached so the second call below
1036+
// is a cache hit — no extra network request.)
10291037
}
10301038
const dedupeEntries = allMessageIds.map((id) =>
10311039
recentInboundMessages.check(`${account.accountId}:${id}`),

0 commit comments

Comments
 (0)