Commit 4db158d
Ciprian Cosma
fix(whatsapp): resolve LID↔phone aliases in Python DM allowlist
Baileys 7.x delivers 1:1 message sender IDs in LID format
(e.g. `<numeric>@lid`) while user allowlists typically use
phone numbers with `+` prefix (e.g. `+<numeric>`).
The JS bridge already handles this — `scripts/whatsapp-bridge/allowlist.js`
strips the `+` prefix and walks `lid-mapping-<id>{,_reverse}.json`
files Baileys writes to the session directory, so either form
resolves to the other. The Python adapter does not:
# Old _is_dm_allowed
return sender_id in self._allow_from # always False for LID senders
This silently drops every WhatsApp DM after the JS bridge queues
it — no error in gateway.log, no notification, just a `[]` response
to repeated `/messages` polls. Outbound keeps working (different
code path), so the symptom is "WhatsApp stopped replying" rather
than "WhatsApp is broken."
Fix: mirror the JS allowlist walk in `WhatsAppBehaviorMixin` via two
new helpers — `_lid_aliases()` resolves a sender ID to all known
aliases (phone ↔ LID) by walking the same mapping files the JS bridge
reads, and `_sender_in_allowlist()` checks the DM allowlist against
every alias. `_is_dm_allowed` now dispatches to it when policy is
`allowlist`.
Mixins don't see host-adapter attributes through static analysis, so
the `_allow_from` read carries a `# type: ignore[attr-defined]`
comment with a pointer to the documented mixin contract at the top of
the file. New `Path` import required for the file-system walk.
Symptom: WhatsApp DMs stop working after a Hermes update or any time
the bridge reconnects; outbound keeps working. Verified with bridge
debug logs showing the JS allowlist passing but the Python gate
silently rejecting every message until this fix was deployed.1 parent 6681f28 commit 4db158d
1 file changed
Lines changed: 62 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
148 | 149 | | |
149 | 150 | | |
150 | 151 | | |
151 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
155 | | - | |
| 162 | + | |
156 | 163 | | |
157 | 164 | | |
158 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
159 | 219 | | |
160 | 220 | | |
161 | 221 | | |
| |||
0 commit comments