Skip to content

Conversation

@commander-alexander
Copy link

@commander-alexander commander-alexander commented Jan 31, 2026

Summary

[This PR was closed and replaced by #5655 - content removed for privacy]

…umber

When the Mac has multiple iMessage numbers (e.g., dual-SIM setup), messages
to ALL numbers are received. This adds a myNumbers config option that filters
messages by destination_caller_id, so the bot only responds to messages sent
to the configured number(s).

Config example:
{
  channels: {
    imessage: {
      myNumbers: ["+16466128299"]
    }
  }
}

Requires imsg to expose destination_caller_id (see steipete/imsg#29).
@openclaw-barnacle openclaw-barnacle bot added the channel: imessage Channel integration: imessage label Jan 31, 2026
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +216 to +228
const myNumbers = imessageCfg.myNumbers;
if (myNumbers && myNumbers.length > 0) {
const destinationCallerId = message.destination_caller_id;
if (destinationCallerId) {
const normalizedDest = normalizeIMessageHandle(destinationCallerId);
const normalizedMyNumbers = myNumbers.map((n) => normalizeIMessageHandle(n));
if (!normalizedMyNumbers.includes(normalizedDest)) {
logVerbose(
`imessage: skipping message to ${destinationCallerId} (not in myNumbers: ${myNumbers.join(", ")})`,
);
return;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] myNumbers filter is bypassed when destination_caller_id is missing

In handleMessageNow, the filter only runs if destinationCallerId is truthy (if (destinationCallerId) { ... }). If imsg is older (or sends null/empty) then messages will be processed even when myNumbers is configured, which undermines the main safety goal (avoid responding on the wrong number). Consider treating missing destination_caller_id as non-matching (skip) when myNumbers is set, or at least logging a clear warning so operators know the filter isn’t being applied.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/imessage/monitor/monitor-provider.ts
Line: 216:228

Comment:
[P1] `myNumbers` filter is bypassed when `destination_caller_id` is missing

In `handleMessageNow`, the filter only runs if `destinationCallerId` is truthy (`if (destinationCallerId) { ... }`). If `imsg` is older (or sends `null`/empty) then messages will be processed even when `myNumbers` is configured, which undermines the main safety goal (avoid responding on the wrong number). Consider treating missing `destination_caller_id` as non-matching (skip) when `myNumbers` is set, or at least logging a clear warning so operators know the filter isn’t being applied.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +221 to +224
const normalizedMyNumbers = myNumbers.map((n) => normalizeIMessageHandle(n));
if (!normalizedMyNumbers.includes(normalizedDest)) {
logVerbose(
`imessage: skipping message to ${destinationCallerId} (not in myNumbers: ${myNumbers.join(", ")})`,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Avoid per-message re-normalization of myNumbers

normalizedMyNumbers is recomputed on every inbound message (myNumbers.map(normalizeIMessageHandle)), even though imessageCfg.myNumbers is static for the provider lifetime. Precomputing a Set of normalized numbers once (outside handleMessageNow) would avoid repeated allocations and make the membership check O(1).

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/imessage/monitor/monitor-provider.ts
Line: 221:224

Comment:
[P3] Avoid per-message re-normalization of `myNumbers`

`normalizedMyNumbers` is recomputed on every inbound message (`myNumbers.map(normalizeIMessageHandle)`), even though `imessageCfg.myNumbers` is static for the provider lifetime. Precomputing a `Set` of normalized numbers once (outside `handleMessageNow`) would avoid repeated allocations and make the membership check O(1).

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant