Skip to content

Commit 1ee4a16

Browse files
committed
fix: exclude DM participant lists from iMessage self-chat check
1 parent b8af4d6 commit 1ee4a16

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

extensions/imessage/src/monitor/inbound-processing.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,8 @@ export function resolveIMessageInboundDecision(params: {
207207
const chatIdentifierNormalized = normalizeIMessageHandle(chatIdentifier ?? "") || undefined;
208208
const destinationCallerIdNormalized =
209209
normalizeIMessageHandle(destinationCallerId ?? "") || undefined;
210-
const chatParticipantHandles = new Set(
211-
(params.message.participants ?? [])
212-
.map((participant) => normalizeIMessageHandle(participant))
213-
.filter((participant): participant is string => participant.length > 0),
214-
);
215210
const matchesSelfChatDestination =
216-
destinationCallerIdNormalized == null ||
217-
destinationCallerIdNormalized === senderNormalized ||
218-
chatParticipantHandles.has(destinationCallerIdNormalized);
211+
destinationCallerIdNormalized == null || destinationCallerIdNormalized === senderNormalized;
219212
const isSelfChat =
220213
!isGroup &&
221214
chatIdentifierNormalized != null &&

extensions/imessage/src/monitor/self-chat-dedupe.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ describe("self-chat is_from_me=true handling (Bruce Phase 2 fix)", () => {
393393
expect(decision.kind).toBe("dispatch");
394394
});
395395

396-
it("preserves self-chat when destination_caller_id is another local handle", () => {
396+
it("drops DM false positives even when participant lists include the local handle", () => {
397397
const echoCache = createSentMessageCache();
398398
const selfChatCache = createSelfChatCache();
399399

@@ -405,18 +405,18 @@ describe("self-chat is_from_me=true handling (Bruce Phase 2 fix)", () => {
405405
chat_identifier: "+15551234567",
406406
destination_caller_id: "me@icloud.com",
407407
participants: ["+15551234567", "me@icloud.com"],
408-
text: "Hello from my other local handle",
408+
text: "Hello from a normal DM row",
409409
is_from_me: true,
410410
is_group: false,
411411
},
412-
messageText: "Hello from my other local handle",
413-
bodyText: "Hello from my other local handle",
412+
messageText: "Hello from a normal DM row",
413+
bodyText: "Hello from a normal DM row",
414414
echoCache,
415415
selfChatCache,
416416
}),
417417
);
418418

419-
expect(decision.kind).toBe("dispatch");
419+
expect(decision).toEqual({ kind: "drop", reason: "from me" });
420420
});
421421

422422
it("drops agent reply echo in self-chat (is_from_me=true, echo cache text match)", () => {

0 commit comments

Comments
 (0)